Alternative Wizard Dialog

Download demo 141K

wiz_dialog.gif (36)

1. Using this dialog

This is a simple demo for a “wizard-like” dialog; it shows how you can handle child dialogs.

It’s use is simple. Here are the steps you need:

  • create the dialog pages for the wizard controls using
    dialogs without title, border, system menu, with the “visible” flag turn off and the “control”
    and “control parent” flags turn on.
  • create the dialog classes for these sheets
  • to invoke the wizard dialog, do something like this:

    CWizardDlg dlg;

    dlg.csTitle = “This is a test wizard”;

    CTestPage1 page1;
    CTestPage2 page2;
    CTestPage3 page3;

    dlg.AddPage(“Page 1\tsmall description of step 1”, &page1, CTestPage1::IDD);
    dlg.AddPage(“Page 2\tsmall description of step 2”, &page2, CTestPage2::IDD);
    dlg.AddPage(“Page 3\tsmall description of step 3”, &page3, CTestPage3::IDD);


    The dlg.csTitle will specify the title of the wizard dialog.
    The parameters for the AddPage function are this:

    • name and description, separated by a \t caracther
    • pointer to the page dialog
    • the page dialog ID

This way works well if no page need data from other pages. Otherwise you’ll need to derive a class
from CWizardDlg and override the virtual function SetCurSel.
In the demo, I putted a sample for the normal CWizardDlg and one for a derived one. In the
derived one we take an integer from an edit control in page2 and insert it*2 in an edit on
page 3.
A derived class can be like this:

class CCustomWizardDlg : public CWizardDlg
virtual void SetCurSel(const int idx);

void CCustomWizardDlg::SetCurSel(const int idx)
if (idx == 2)
CTestPage2 * p2 = (CTestPage2 *) GetDialog(1);
CTestPage3 * p3 = (CTestPage3 *) GetDialog(2);
p3->iTestInt = p2->iTestInt * 2;

The text resource for buttons (back, next, cancel, end) are stored as define and not as string resource.
You can find them at beginning of wizarddlg.cpp file.

2. What do I need to use the dialog ?

You’ll have to add/insert as components the CNetButton and the CWizardDlg classes.
You’ll also have to provide a bitmap to be used and set it in the IDD_WIZARDBASE dialog template.
The dialogs page will be automatically fitted into the frame in the IDD_WIZARDBASE dialog; resize this
frame to accomplish the desired size.

Last updated: 28 June 1998

More by Author

Must Read