(SDK编程)如何设置鼠标移到一个BUTTON时,它的鼠标样式为手指,移出BUTTON,恢复原样,现在关键是如何判断鼠标移出了BUTTON?

解决方案 »

  1.   

    根本不用判断位置:
    case WM_SETCURSOR:
    if (hBtn == (HWND)wParam)
    {
    SetCursor(LoadCursor(NULL, IDC_HAND));
    return 1;
    }
    return DefWindowProc(hWnd, message, wParam, lParam);
    break;
      

  2.   

    在mouse的onmove消息中,判断鼠标当前位置是否在button的rect中
      

  3.   

    获取按钮句柄,然后再setcursor把鼠标换成你所想要的.
      

  4.   


    BOOL CXXXXXXDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
    {
    // TODO: Add your message handler code here and/or call default
    switch(pWnd->GetDlgCtrlID())
        {
        case IDC_BUTTON1:
            SetCursor(::LoadCursor(NULL, IDC_HAND));
            break;
        default :
            SetCursor(::LoadCursor(NULL, IDC_ARROW));
        }
        
        return TRUE;}