Visual C++ and MFC Fundamentals Chapter 12: Dialog-Based Windows
The main area of this bar contains a word or a group of words forming a sentence called a
caption. There are various ways you can change it. At design time, on the Properties
window, change the value of the Caption field. If you are creating a resource file, start a
new line with the CAPTION keyword and provide the word or group of words as a null-
terminated string. Here is an example:
IDD_SCHOOL_SURVEY DIALOGEX 0, 0, 340, 268
STYLE WS_CAPTION
CAPTION “School Survey – For Teachers Only”
WS_SYSMENU: By convention, a dialog box is equipped with only the system Close
button on its title bar. This is made possible by adding the WS_SYSMENU style:
IDD_SCHOOL_SURVEY DIALOGEX 0, 0, 340, 268
STYLE WS_CAPTION | WS_SYSMENU
CAPTION “School Survey – For Teachers Only”
WS_MINIMIZEBOX: The Minimize and Maximize buttons are omitted. If you want to
add the Minimize button , at design time, set the Minimize Box property to True or
checked. This is equivalent to adding the WS_MINIMIZEBOX style to the class.
WS_MINIMIZE: If you create a dialog box and equip it with the Minimize button so the
user can shrink it to the Taskbar, if you want the dialog box to be minimized when it
comes, you can open the resource file and add the WS_MINIMIZE style. This would be
done as follows:
IDD_SCHOOL_SURVEY DIALOGEX 0, 0, 340, 268
STYLE WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MINIMIZE
CAPTION “School Survey – For Teachers Only”
Remember that a dialog box can be minimized only if its system menu indicates so.
WS_MAXIMIZEBOX: If you want the Maximize button , set the Maximize Box
property to True or checked. This is equivalent to adding the WS_MAXIMIZEBOX
style.
WS_MAXIMIZE: If you create a dialog box equipped with the Maximize button, if you
want the dialog box to be automatically maximized when it displays, you can add the
WS_MAXIMIZE style to the resource file. This would be done as follows:
IDD_SCHOOL_SURVEY DIALOGEX 0, 0, 340, 268
STYLE WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MINIMIZE |
WS_MINIMIZEBOX | WS_MINIMIZE
CAPTION “School Survey – For Teachers Only”
Remember that a window box can be maximized only if it includes the
WS_MAXIMIZEBOX style.
Setting one of these two system button properties to True or checked or adding either
WS_MAXIMIZEBOX or WS_MINIMIZEBOX and not the other would disable the
other system button. Therefore, here are the combinations you can get: