Chapter 12: Dialog-Based Windows Visual C++ and MFC Fundamentals
DS_CENTERMOUSE: We have described how to control the location of the dialog box
when it comes up, depending on the coordinate system you are using, and the
DS_CENTER style. Alternatively, if you want the dialog box to be displayed based on
the location of the user’s mouse cursor, set its Center Mouse property to True or checked.
In this case, when the dialog box comes up, it would find the mouse pointer and position
itself so the mouse cursor would be in the middle-center of the dialog box. This ability is
also applied by adding the DS_CENTERMOUSE style.
Font: To display its controls, the dialog box uses a predefined font known as MS Shell
Dlg. To change it at design time, if you are using MSVC 6, click the Font button in the
General property page of the Properties window. In MSVC 7, you can click the ellipsis
button of the Font (Size) field. The font characteristics are managed through the
DS_SHELLFONT, the DS_SETFONT, and the DS_FIXEDSYS styles. The section of
the resource file that specifies the general font starts with the FONT keyword:
IDD_SCHOOL_SURVEY DIALOGEX 0, 0, 340, 268
STYLE WS_CAPTION | WS_SYSMENU | WS_POPUP | DS_MODALFRAME
CAPTION “School Survey – For Teachers Only”
FONT
The FONT keyword is followed by the characteristics of the font using the following
syntax:
FONT size, name, weight, italic, charset
Here is an example:
IDD_SCHOOL_SURVEY DIALOGEX 0, 0, 340, 268
STYLE WS_CAPTION | WS_SYSMENU | WS_POPUP | DS_MODALFRAME
CAPTION “School Survey – For Teachers Only”
FONT 8, “MS Shell Dlg”, 400, 0, 0x1
If you want to manage the fonts, weights, and colors of the controls on the dialog box of
an MFC application, you must do this programmatically.
Practical Learning: Using Dialog Box Properties
- In the properties window, click the arrow of the Border combo box and select
Resizing - Click the Center check box or set it to True
12.1.7..Extended Windows Styles for a Dialog Box..................................
Windows extended styles are used to improve the appearance or the role of a dialog box
on an application. To use these styles in the resource file, start a new line with the
EXSTYLE keyword:
IDD_SCHOOL_SURVEY DIALOGEX 0, 0, 340, 268
STYLE WS_CAPTION | WS_SYSMENU | WS_POPUP | DS_MODALFRAME
EXSTYLE
CAPTION “School Survey – For Teachers Only”
FONT 8, “MS Shell Dlg”, 400, 0, 0x1