在对话框中加了些按钮,想实现当鼠标在按钮上 时变成CROSS在BOOL CTestDlg::OnInitDialog()中添加
(CButton*)GetDlgItem(ID_OK)->SetCursor(::LoadCursor(NULL,IDC_CROSS));
编译提示
error C2039: 'SetCursor' : is not a member of 'CWnd'
f:\computer\programming\vc98\mfc\include\afxwin.h(1899) : see declaration of 'CWnd' 我在 前面不是已经强制转换了吗???怎么还是CWND而且在MSDN中他是这么写的 :
CButton myButton;// Create an icon button.
myButton.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_ICON,
CRect(10,10,60,50), pParentWnd, 1);// Set the image of the button to be the system arrow and
// small hourglass cursor.
myButton.SetCursor( ::LoadCursor(NULL, IDC_APPSTARTING) );我觉得和我 的 代码没什么区别啊。哪位高手解释一下 ~~~~
(CButton*)GetDlgItem(ID_OK)->SetCursor(::LoadCursor(NULL,IDC_CROSS));
编译提示
error C2039: 'SetCursor' : is not a member of 'CWnd'
f:\computer\programming\vc98\mfc\include\afxwin.h(1899) : see declaration of 'CWnd' 我在 前面不是已经强制转换了吗???怎么还是CWND而且在MSDN中他是这么写的 :
CButton myButton;// Create an icon button.
myButton.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_ICON,
CRect(10,10,60,50), pParentWnd, 1);// Set the image of the button to be the system arrow and
// small hourglass cursor.
myButton.SetCursor( ::LoadCursor(NULL, IDC_APPSTARTING) );我觉得和我 的 代码没什么区别啊。哪位高手解释一下 ~~~~
((CButton*)GetDlgItem(ID_OK))->SetCursor(::LoadCursor(NULL,IDC_CROSS));
//SetCursor(AfxGetApp()->LoadCursor(MAKEINTRESOURCEA(32649)));//默认手状2.
HCURSOR hCursor = LoadCursor(NULL,MAKEINTRESOURCEA(32649));
SetCursor(hCursor);
这两个是系统自带的形状,当然你也可以自己定义图标
要设置鼠标的光标形状,响应WM_SETCURSOR消息,在里面判断所处的位置,然后用::SetCursor()来设置。