将鼠标移动到Button1上时的图标变成手形状的方法

来源:岁月联盟 编辑:zhu 时间:2009-02-24
下面代码将鼠标移动到Button1上时的图标变成手形状:
Step1:
在cpp顶部添加下面代码:
#undef WINVER
#define WINVER 0x500
#if(WINVER >= 0x0500)
#define IDC_HAND MAKEINTRESOURCE(32649)
#endif
Step2:
重载消息OnSetCursor
BOOL CTestDlg::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;

//return CDialog::OnSetCursor(pWnd, nHitTest, message);
}

图片内容