Collapse the table of content
Expand the table of content


The framework calls this member function when the cursor is in an inactive window and the user presses a mouse button.

afx_msg int OnMouseActivate(
   CWnd* pDesktopWnd,
   UINT nHitTest,
   UINT message 


Specifies a pointer to the top-level parent window of the window being activated. The pointer may be temporary and should not be stored.


Specifies the hit-test area code. A hit test is a test that determines the location of the cursor.


Specifies the mouse message number.

Specifies whether to activate the CWnd and whether to discard the mouse event. It must be one of the following values:

  • MA_ACTIVATE   Activate CWnd object.

  • MA_NOACTIVATE   Do not activate CWnd object.

  • MA_ACTIVATEANDEAT   Activate CWnd object and discard the mouse event.

  • MA_NOACTIVATEANDEAT   Do not activate CWnd object and discard the mouse event.

The default implementation passes this message to the parent window before any processing occurs. If the parent window returns TRUE, processing is halted.

For a description of the individual hit-test area codes, see the OnNcHitTest member function


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.

// The code fragment below shows how to UI activate an ActiveX control.
// CMyAxCtrl is a COleControl-derived class.
int CMyAxCtrl::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
   OnActivateInPlace(TRUE, NULL);  // OnActivateInPlace() is an undocumented function
   return COleControl::OnMouseActivate(pDesktopWnd, nHitTest, message);

Header: afxwin.h

Community Additions

© 2015 Microsoft