更改MFC中按钮的光标
Changing Cursor of a button in MFC
我正在尝试更改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
相关文章:
- 如何在Qt C++中更改光标
- 问:如何使用C++中的按钮从窗口打开窗口
- 如何将点击的信号和插槽添加到qt中的自定义按钮中
- QML按钮点击功能执行顺序
- 当用户超过按钮点击限制时报告
- 函数计算用户按下按钮的频率
- 热键/按钮,根据需要进行编译,但不运行(在F5和Ctrl+Shift+B之间)
- FLTK:按下哪个按钮 - 将数字传递给按钮的回调 (lambda)
- 如何通过按下第三个窗口中的按钮,将QString从一个窗口获取到另一个窗口
- 垂直方向的 Gtk3+ 旋转按钮 (c/c++)
- Qt自定义QPush按钮未显示在布局上
- SDL 操纵杆按钮按下/C++
- 如何使用按钮更新GTK3图像以使用C++从相机捕获图片
- Qt中来自不同功能的按钮引用
- WinAPI 在单击第一个对话框上的按钮控件并销毁第一个对话框后创建第二个对话框
- 自定义光标未显示在自定义按钮上
- 更改MFC中按钮的光标
- 如何确定鼠标是否指向光标下窗口的最大按钮
- 如何在单击按钮时更改光标
- MFC不可点击按钮(从鼠标移动的光标逃跑)