In part three of this ten part series, Mitchell talks about modal and modeless dialog boxes. "To create a fully interactive user experience, any application must employ some sort of dialog-based interaction. Dialog boxes come in two flavors: modal and modeless..."
DialogId: The id that we will use to reference our dialog box. Can be either a string of text, or a #defined ID. We have used TestDialog, which is interpreted by C++ a string of text, because we haven’t #defined an ID named TestDialog.
DIALOG: The dialog keyword tells the C++ resource compiler that we are creating a new dialog box. If we wanted to create a dialog box with extended styles, we would use DIALOGEX instead.
xPos: The x-coordinate from which our dialog box will be positioned when it is loaded. This co-ordinate is relative to the parent window of the dialog box (if any).
yPos: The y-coordinate from which our dialog box will be positioned when it is loaded. This co-ordinate is relative to the parent window of the dialog box (if any).
width: The width of the dialog resource, in logical units (pixels).
height: The height of the dialog resource in logical units (pixels).
CAPTION "My Test Dialog Box"
This line simply sets the window caption of our dialog resource.
The third line of our dialog resource defines how it will look. Firstly, we have the keyword STYLE. STYLE is suffixed with four different MFC defined style macros:
DS_MODALFRAME: Our dialog box can be modal
WS_VISIBLE: Our dialog resource will be visible when it is loaded
WS_CHILD: Our dialog box can have a parent window
WS_SYSMENU: Our dialog box will have a system menu. A system menu simply means that when the icon in the title bar of the dialog resource is clicked, several menu items such as Restore, Minimize and Close will be displayed.
// Controls on the dialog will go here
Lastly, we have the “contents” of our dialog resource. As you can see, ours is empty. We will place resources for radio buttons, edit boxes, check boxes, etc in our dialogs contents soon. Instead of using opening and closing braces, we could use BEGIN and END respectively, however, I think that braces make our resource file easier to read.
We have just created our dialog resource. To actually make our dialog resource visible through our application, we have to encapsulate it within a class. We will do that now.