开发者

Set Cursor for child control from parent window?

How can you set cu开发者_StackOverflowrsor for a child window from parent window without subclassing it?


The WM_SETCURSOR message automatically gets passed to the parent so you can handle it there. If the child control actually handles it then you'll have to sub-class it. Or hack the message loop (yuck).


TCHAR szButtonCoordinates[50];
RECT  rect;
switch (message)
{
...
case WM_MOUSEMOVE:
     hWndButton = GetDlgItem (hWnd, IDC_BUTTON);
     GetClientRect (hWndButton, &rect);
     MapWindowPoints (hWndButton, hWnd, (LPPOINT) &rect, 2);
     // wsprintf (szButtonCoordinates, _T("Top: %d, Left: %d, Bottom: %d, Right: %d."),rect.top, rect.left,  rect.bottom, rect.right);
     if (((LOWORD (lParam) >= rect.left) && (LOWORD (lParam) <= rect.right)) && ((HIWORD (lParam) >=rect.top) && (HIWORD (lParam) <= rect.bottom)))
     {
         //MessageBox (hWndProg3, szButtonCoordinates, _T("Button Coordinates"), MB_ICONINFORMATION);
         SetCursor (LoadCursor (NULL, IDC_CROSS));
      }
      break; 
...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜