Chapter 12: Dialog-Based Windows Visual C++ and MFC Fundamentals
- In the last step, in the Base Class combo box, select CformView
- Click Finish
- To display the form, in the Resource View, expand the Dialog folder and double-
click IDD_FORMBASED1_FORM - In the Properties window, notice that its Style is set to Child and its Border is set to
None - Press Ctrl + F5 to test the application
- After viewing it, return to MSVC
- Controls Designs on Forms and Dialog Boxes
13.2 Dialog Box Messages and Events.............................................................
In this section, unless specified otherwise, the expressions “dialog box” or “dialog-
based object” refer to the regular dialog box, the property sheet, the property page, or
the flat dialog-window that composes a form.
13.2.1..The Dialog Box as a Control Initializer...........................................
As the most regularly used host of Windows Controls, a dialog box most be able to
handle messages that not only pertain to its own existence but also to the availability,
visibility, and behaviors of the controls it is holding. For example, if you create a control
and position it on the dialog box, sometimes you will need to initialize, give it primary
values. Although the dialog box provides a constructor and even inherits the
WM_CREATE message along with the PreCreateWindow() event from its parent the
CWnd class, if you need to initialize a control, the CDialog box and its cousins
CPropertySheet, CPropertyPage, and the form provide a special event you can use to do
this.
WM_INITDIALOG: The WM_INITDIALOG message fires the OnInitDialog() event
after a dialog, a property sheet, a property page, or a form has been created but before this
window is displayed. It is the equivalent of the PreCreateWindow() event used by other
frame and view-based window. This event should be your favorite place to initialize a
control that is hosted by the dialog-based object. Do not initialize controls in your