c – 更改MFC中按钮的光标
发布时间:2020-12-16 07:28:54 所属栏目:百科 来源:网络整理
导读:我试图在MFC对话框中更改按钮的光标.我用过 BOOL CStartDlg::OnSetCursor(CWnd* pWnd,UINT nHitTest,UINT message){if ( m_changeCursor ){ ::SetCursor(AfxGetApp()-LoadStandardCursor(IDC_HAND)); return TRUE;}return CDialog::OnSetCursor(pWnd,nHitTes
我试图在MFC对话框中更改按钮的光标.我用过
BOOL CStartDlg::OnSetCursor(CWnd* pWnd,UINT nHitTest,UINT message) { if ( m_changeCursor ) { ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND)); return TRUE; } return CDialog::OnSetCursor(pWnd,nHitTest,message); } 但它正在改变整个对话框的光标. m_button是CButton类的对象. m_button1.SetCursor(::LoadCursor(NULL,IDC_HAND)); 解决方法
调用LoadCursor()函数并将其返回的值传递给CMFCButton :: SetMouseCursor()成员函数.这是一个例子:
BOOL CExerciseDlg::OnInitDialog() { CDialogEx::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon,TRUE); // Set big icon SetIcon(m_hIcon,FALSE); // Set small icon // TODO: Add extra initialization here m_Calculate.SetMouseCursor(LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_CURSOR1))); return TRUE; } 参考http://www.functionx.com/visualc/controls/mfcbtn.htm#subtitle 也请参考Api CWinApp::LoadCursor (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |