This documentation is archived and is not being maintained.


Updated: May 2009

This method is the default CWnd handler for the WM_SETCURSOR message.

The framework calls this member function if mouse input is not captured and the mouse causes cursor movement within the CWnd object.

afx_msg BOOL OnSetCursor( 
   CWnd* pWnd, 
   UINT nHitTest, 
   UINT message  


Specifies a pointer to the window that contains the cursor. The pointer may be temporary and should not be stored for later use.


Specifies the hit-test area code. The hit test determines the location of the cursor.


Specifies the mouse message number.

Nonzero to halt further processing, or 0 to continue.

The default implementation calls the parent window's OnSetCursor before processing. If the parent window returns TRUE, further processing is halted. Calling the parent window gives the parent window control over the cursor's setting in a child window.

The default implementation sets the cursor to an arrow if it is not in the client area or to the registered-class cursor if it is.

The message parameter is 0 when CWnd enters menu mode.


This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.

Header: afxwin.h




May 2009

Revised Remarks; added reference to WM_SETCURSOR in introduction.

Information enhancement.