改变光标形状

1.重载OnSetCursor

 

HCURSOR hcursor;

 

BOOL CT_20Dlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
 // TODO: Add your message handler code here and/or call default
    SetCursor(hcursor);
    return true;
 return CDialog::OnSetCursor(pWnd, nHitTest, message);
}

 

2.设置光标

void CT_20Dlg::OnLButtonUp(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 hcursor=AfxGetApp()->LoadCursor(IDC_CURSOR2);       //加载自定义光标
 this->OnSetCursor(this, HTNOWHERE,WM_SETCURSOR); 
 CDialog::OnLButtonUp(nFlags, point);
}

void CT_20Dlg::OnLButtonDown(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
  hcursor=AfxGetApp()->LoadCursor(IDC_CURSOR1);       //加载自定义光标
 this->OnSetCursor(this, HTNOWHERE,WM_SETCURSOR); 
 CDialog::OnLButtonDown(nFlags, point);
}


版权声明:本文为dongfangyu原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。