Alternative Wizard Dialog | CodeGuru

Alternative Wizard Dialog

Download demo 141K 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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Aug 7, 1998
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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);
    dlg.DoModal();
    

    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
{
public:
	virtual void SetCurSel(const int idx);
};

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

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

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.