I’m trying to change the cursor inside my CStatic-derived class by handling 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;
}
OnSetCursor gets called every time I move the mouse, but the cursor isn’t changed. What am I doing wrong?
use ::SetCursor. Or you can call SetCursor once elsewhere and don’t capture WM_SETCURSOR, and the cursor will be set automatically.
The CWnd::SetCursor you used is for setting a cursor for a window, and that cursor will be used if you don’t override OnSetCursor. That is, the default behavior of OnSetCursor is calling ::SetCursor with the cursor one set by calling CWnd::SetCursor.