设置鼠标的光标!指定位置光标,按下左键右键时的光标

时间:2021-06-24 19:06:24

定义手型光标 #define IDC_HAND            MAKEINTRESOURCE(32649)

void CMyDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default

 ::SetCursor(::LoadCursor(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_CURSOR1)));//自己做的鼠标光标


 CDialog::OnLButtonUp(nFlags, point);
}

void CMyDlg::OnRButtonUp(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 HCURSOR cusor=AfxGetApp()->LoadStandardCursor(IDC_CROSS);//直接从系统中找
 SetCursor(cusor);

 

(或者直接这样: ::SetCursor((::LoadCursor(NULL, IDC_HAND))); )
 CDialog::OnRButtonUp(nFlags, point);
}

 

void CMyDlg::OnMouseMove(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 if(point.x < 250 && point.y < 250
  && point.x >12 && point.y > 12)
    {   //设定鼠标样式
        ::SetCursor(::LoadCursor(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_CURSOR1)));
    }
 

 CDialog::OnMouseMove(nFlags, point);
}