Window Activation

When the user clicks an inactive top-level window or the child window of a inactive top-level window, Windows sends the WM_MOUSEACTIVATE message (among others) to the top-level or child window. Windows sends this message after posting the WM_NCHITTEST message to the window, but before posting the button down message. When WM_MOUSEACTIVATE is passed to the DefWindowProc function, Windows activates the top-level window and then posts the button down message to the top-level or child window.

By processing WM_MOUSEACTIVATE, a window can control whether the top-level window becomes the active window as a result of a mouse click, and whether the window that was clicked receives the subsequent button down message. It does so by returning one of the following values after processing WM_MOUSEACTIVATE.

Value Meaning
MA_ACTIVATE Activates the window and does not discard the mouse message.
MA_NOACTIVATE Does not activate the window and does not discard the mouse message.
MA_ACTIVATEANDEAT Activates the window and discards the mouse message.
MA_NOACTIVATEANDEAT Does not activate the window but discards the mouse message.