我正在尝试通过处理 OnSetCursor
来更改我的 CStatic
派生类中的光标
class CMyStatic : public CStatic
{
// ....
};
BEGIN_MESSAGE_MAP(CMyStatic, CStatic)
ON_WM_SETCURSOR()
END_MESSAGE_MAP()
BOOL CMyStatic::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
TRACE(_T("OnSetCursor\n"));
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
return TRUE;
}
每次我移动鼠标时都会调用 OnSetCursor
,但光标没有改变。我做错了什么?
最佳答案
使用::SetCursor。或者您可以在别处调用一次 SetCursor 并且不捕获 WM_SETCURSOR,光标将自动设置。
您使用的 CWnd::SetCursor 用于为窗口设置光标,如果您不覆盖 OnSetCursor,将使用该光标。也就是说,OnSetCursor 的默认行为是使用通过调用 CWnd::SetCursor 设置的光标调用::SetCursor。
关于c++ - 无法更改光标(从 OnSetCursor 内部),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10205064/