Hey, how can I check to see if the mouse cursor is over a button and if it is then change the mouse cursor?
Hey, how can I check to see if the mouse cursor is over a button and if it is then change the mouse cursor?
When you get the mouse move message, the high part of lparam is the y cordinate, and the low part of lparam is the x cordinate.
You could sublass the button and trap the messages...
Using spy++ it looks like the button would recieve, WM_MOUSEMOVE, WM_SETCURSOR and WM_NCHITTEST....
Try trapping one or a few of these and see if you get any results
there's like a WM_MOUSEOVER or WM_MOUSEHOVER or something message you could trap if you subclass it. I forget the exact message name.
Look up ChildWindowFromPoint();
HWND ChildWindowFromPoint(
HWND hWndParent, // handle to parent window
POINT Point // structure with point coordinates
);
use WM_MOUSEMOVE and make somthing like this i have never tried this so i dunno if it will work
Code:case WM_MOUSEMOVE: { POINT pt; HWND hRet; pt.x = LOWORD(lParam); pt.y = HIWORD(lParam); hRet = ChildWindowFromPoint(hWnd, pt); if(hRet == hWndMyButton) { //yea do some stuff } else { //it isnt on that button } }
I read up that function in my book casue i had been wanting to do the same thing, but for some reason i never got around to testing it . If you want to check multiple handles your gonna have to make a big nested structure of ifs and eleses....
Hope that helps/works,
TNT
TNT
You Can Stop Me, But You Cant Stop Us All
Ok, this is wierd. When I use the code below the message box comes up saying it isn't over when the mouse is on the dialog box. However when the mouse is over any control such as a button nothing comes up.
case WM_MOUSEMOVE:
POINT pt;
HWND hRet;
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
hRet = ChildWindowFromPoint(hwnd, pt);
if(hRet == GetDlgItem(hwnd, IDC_BANNERSITE))
{
MessageBox(hwnd, "is over banner", "mouse", MB_OK);
}
else
{
MessageBox(hwnd, "isn't over banner", "mouse", MB_OK);
}
break;
Watch the client area cood's v's screen cood's as this may be your problem.
How about PtInRect() function
Check each mouse move msg to see if the mouse is in the buttons area (GetWindowRect() )
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill