Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 5: The Document/View Architecture


To manage this setting, the windows are organized in a 3-dimensional coordinate system
and they are incrementally positioned on the Z coordinate, which defines the (0, 0, 0)
origin on the screen (actually on the top-left corner of your monitor) with Z coordinate
coming from the screen towards you.

In order to use a window other than the one that is active, you must activate it. To do this,
you can send a message called ON_WM_ACTIVATE. The syntax of this message is:

afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);

This message indeed does two things: it activates a window of your choice, or brings it to
the front, and deactivates the other window(s) or sends it/them to the back of the window
that is being activates. The nState argument specifies what action to apply. It is a
constant that can assume of the following values:

Value Description
WA_ACTIVE Used to activate a window without using the mouse, may be by
pressing Alt + Tab
WA_INACTIVE Used to deactivate a window
WA_CLICKACTIVE Used to activate a window using the mouse

If this message was sent by the window that is being activated, pWndOther designates the
other window, the one being deactivated. If this message was sent by the window that is
being deactivated, pWndOther designates the other window, the one being activated.
Free download pdf