Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 2: Introduction to MFC


Figure 25: The Title Bar of a Frame...........................................................................................


A window is identified by its size which can be seen by its borders. Borders are given to
a window through the WS_BORDER value for the style. As you can see from the above
window, using the WS_CAPTION style also gives borders to a window.

A shortcut to creating a window that has a caption and a border is done by using the
WS_OVERLAPPED style:

Create(NULL, "Windows Application", WS_OVERLAPPED);

As you will see shortly, various styles can be applied to the same window. To combine
styles, you use the bitwise OR operator represented by the beam symbol |. For example, if
you have a style called WS_ONE and you want to combine it with the WS_OTHER
style, you can use WS_ONE | WS_OTHER.

The title bar serves various purposes. For example, it displays the name of the window. In
this case the window is called Window Application. The title bar also allows the user to
move a window. To do this, the user would click and drag a section of the title bar while
moving in the desired direction.

After using a window, the user may want to close it. This is made possible by using or
adding the WS_SYSMENU style. This style adds a button with X that is called the

System Close button or. Here is an example:

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

Figure 26: A Frame with System Menu.....................................................................................


When a window displays, it occupies a certain area of the screen. To access other
windows, for example to reveal a window hidden behind, the user can shrink the size of
the window completely and make it disappear from the screen without closing the
window. This is referred to as minimizing the window. The ability to minimize a window

is made possible with the presence of a system button called Minimize or. To
allow this, you provide or add the WS_MINIMIZEBOX style:

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