The following describes how to create a dialog template that can be used as a
child in another dialog and how to create the child dialog.
The Dialog Template
If you create a dialog template using the default provided by the resource
editor, then you probably want to delete the "Ok" and "Cancel" buttons,
depending on your requirements. Assuming the child will always be in the same
place in the parent dialog you can specify the position in the "x" and "y"
fields of the dialog properties. Then ensure that the following styles are
selected or unselected:
- Style: Child (important)
- Unselect "Title Bar"
- Select "Control" (so the child works as if it is part of the parent)
- Border: Thin (optional; use whatever border, or no border, as
- Select "Visible" (optional; ShowWindow() can be used instead)
Then use the ClassWizard to create a class for the dialog template. I will be
using CChildDlg as the class name.
Creating the Dialog
OnInitDialog for the parent dialog is probably the best place to create the
child. It must be created as a modeless dialog using Create(). Be sure to
include the header for the child dialog in the parent dialog's cpp file. Then in
the parent dialog's class create an instance of the child dialog, such as in the
Then in OnInitDialog the following will create the dialog: