Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 12: Dialog-Based Windows


12.1.6..Dialog Box Styles................................................................................


DS_CONTEXTHELP: We saw already how to manage the title bar and its system
buttons. If you are creating a strict dialog box, one that is equipped with only the system
close button , if you intend to provide help on the dialog box, you can add a context-
sensitive help button to the left of the close button. To do this, set its Context Help
property to True or create it with the DS_CONTEXTHELP style:

DS_MODALFRAME: By design, a dialog box has thick borders and cannot be resized
from its borders or corners, even if the system buttons are available. This characteristic of
dialog boxes is controlled by the Border property. The default border of a dialog box is
Dialog Frame. This is the same as applying the DS_MODALFRAME dialog style:

IDD_SCHOOL_SURVEY DIALOGEX 0, 0, 340, 268
STYLE WS_CAPTION | WS_SYSMENU | WS_POPUP | DS_MODALFRAME
CAPTION “School Survey – For Teachers Only”

DS-3DLOOK: In previous versions of MS Windows, namely Windows NT 3.51, to get a
3 - dimensional appearance, you needed to apply the DS-3DLOOK style. At this time, this
style is added by default.

DS_ABSALIGN: Earlier, when reviewing the techniques of setting the location of a
dialog box, we mentioned that, if the x and the y values, or the X Pos and the Y Pos
properties, are set to 0, the dialog box is positioned in the middle of the screen. This is
because, like all other controls that can act as children of a parent window, the location of
a dialog box is set according to its parent. That is, the location of a dialog box is based on
its ability to be a client (also called child) of another window (called a parent). This
system is referred to as Client Coordinate. If you are creating an application based on a
dialog box, that is, an application whose main or even only container is the dialog box,
such a dialog box does not have a parent. In this case, it does not have a referential
window to base its location on. Consequently, it gets positioned to the middle of the
screen. If you want the location of the dialog box to be based on the monitor screen, set
its Absolute Align property to True. In a resource file, this would be done by adding the
DS_ABSALIGN style. This system is referred as the Screen Coordinate.

DS_CENTER: Based on the coordinate system you decide to use, screen or client, when
the dialog box of a dialog-based application comes up, if you want the dialog to be
centered on the monitor screen, even if you are using the screen coordinate system with
the DS_ABSALIGN style, set its Center property to True or checked. This is also done
by adding the DS_CENTER style. If the dialog box is participating in an application that
is view-based, if you set its Center property to True, it would be centered with regard to
the window that called it.
Free download pdf