Prevent MFC application to change cursor back to d

2020-04-21 08:30发布

问题:

I have written an application which changes the cursor depending on its position within the window client area. However I have noticed that when I click on the left mouse button the cursor changes back to default arrow icon.

I have overridden the afx_msg void CWnd::OnLButtonDown() and do not call any of the base class function in it (it's completely empty).

Any idea what might cause CDialogEx to change the cursor back? What handles the the left click message?

回答1:

Usually, you need to override OnSetCursor(), and there, if the mouse is in a place where you want a specific cursor, you call SetCursor() and return TRUE so that DefWindowProc doesn't reset it back to the default arrow.