我正在尝试CStatic通过处理来更改派生类中的光标OnSetCursor
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;
}
Run Code Online (Sandbox Code Playgroud)
OnSetCursor每次移动鼠标都会被调用,但光标不会改变。我究竟做错了什么?
使用:: SetCursor。或者,您可以在其他任何地方调用一次SetCursor,而不捕获WM_SETCURSOR,光标将自动设置。
您使用的CWnd :: SetCursor用于为窗口设置光标,如果您不覆盖OnSetCursor,则将使用该光标。也就是说,OnSetCursor的默认行为是通过调用CWnd :: SetCursor来调用带有设置的光标的:: SetCursor。