Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 2 Variables and Identifiers Visual C++ and MFC Fundamentals


Figure 27: A Frame with a Minimize Button............................................................................


As opposed to minimizing the window, the user can change its size to use the whole area
of the screen. This is referred to as maximizing the window. This feature is provided

through the system Maximize button or. To allow this functionality, provide or
add the WS_MAXIMIZEBOX style.

If you create a window with the WS_SYSMENU and the WS_MINIMIZEBOX style
but not the WS_MAXIMIZEBOX style, the Maximize button would be disabled and the
user would not be able to maximize the window:

Create(NULL, "Windows Application", WS_VISIBLE | WS_SYSMENU |
WS_MINIMIZEBOX);

Figure 28: A Frame with a Maximize Button............................................................................


On the other hand, if you do not want the user to be able to minimize the window, create
a window with the WS_SYSMENU and the WS_MINIMIZEBOX without the
WS_MAXIMIZEBOX styles:

Create(NULL, "Windows Application", WS_VISIBLE | WS_SYSMENU | WS_MAXIMIZEBOX);

Therefore, if you want to provide all three system buttons, provide their styles.

You can also control whether the window appears minimized or maximized when it
comes up. To minimize the window at startup, apply the WS_MINIMIZE style. On the
other hand, to have a maximized window when it launches, use the WS_MAXIMIZE
style. This style also provides a window with borders. If you had not specified the
WS_CAPTION, you can make sure that a window has borders using the WS_BORDER
value.

One of the effects the user may want to control on a window is its size. For example, the
user may want to narrow, enlarge, shrink, or heighten a window. To do this, the user
would position the mouse on one of the borders, click and drag in the desired direction.
This action is referred to as resizing a window. For the user to be able to change the size
Free download pdf