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);
    
    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



Comments

  • How to do same things, but without MDI?

    Posted by Legacy on 10/18/2001 12:00am

    Originally posted by: Maximus

    Please if some one could help me, please post your answer.
    
    In my case i can't use MDI to call Wizard Dialog.
    In Wizard dialog i trying to do like that:

    BOOL CWizardDlg::OnInitDialog()
    {

    ....
    CTestPage1 page1;
    CTestPage2 page2;
    page2.iTestInt = 10;

    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);
    ....
    ....
    ....
    //and then:

    if (pPages.GetSize() > 0)
    {
    CRect rc;
    wndFrame.GetWindowRect(rc);
    ScreenToClient(rc);
    for (int t = 0; t < pPages.GetSize(); t++)
    {
    CDialog * pDlg1 = GetDialog(t);
    if (pDlg1)
    {
    pDlg1->Create(csIds.GetAt(t), this);
    pDlg1->SetWindowPos(0,rc.left, rc.top, rc.Width(), rc.Height(), SWP_NOZORDER);
    }
    }
    SetCurSel(0);
    }
    SetWindowText(csTitle);
    SetDlgItemText(IDC_BACK, BACK_BTN_TEXT);
    if (pPages.GetSize() > 1) SetDlgItemText(IDOK, NEXT_BTN_TEXT);
    else SetDlgItemText(IDOK, END_BTN_TEXT);

    SetDlgItemText(IDCANCEL, CANCEL_BTN_TEXT);


    return TRUE; // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
    }
    //......

    But it doesn't works. Why?

    Reply
  • Wizardwindow

    Posted by Legacy on 10/16/2001 12:00am

    Originally posted by: Rajat BAl

    I need sample but in this tips are not enough to understand the topic

    Reply
  • Excellent.

    Posted by Legacy on 09/20/1999 12:00am

    Originally posted by: Aykut KILIC

    Almost all useful articles I see here has the signature of Apolloni.
    Thanks to You.

    Reply
  • Need help finishing up the wizard!

    Posted by Legacy on 06/11/1999 12:00am

    Originally posted by: Curtis

    Your wizard is pretty good and I am finding it very useful, however, I have added all the pages I need, and have many variables set from all the different pages. Now what I would like to do is to take all those variables and use them when the user presses the "End" or "Finish" button on the wizard. How do I detect when the "End" button has been pressed? I need to do this from the View class of my application as well, because I am going to be using the variables to draw some things on the screen. Any help you could provide would be greatly appreciated!

    Thanks,
    Curtis

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: May 6, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT While you likely have very good reasons for remaining on WinXP after end of support -- an estimated 20-30% of worldwide devices still are -- the bottom line is your security risk is now significant. In the absence of security patches, attackers will certainly turn their attention to this new opportunity. Join Lumension Vice President Paul Zimski in this one-hour webcast to discuss risk and, more importantly, 5 pragmatic risk mitigation techniques …

  • The impact of a data loss event can be significant. Real-time data is essential to remaining competitive. Many companies can no longer afford to rely on a truck arriving each day to take backup tapes offsite. For most companies, a cloud backup and recovery solution will eliminate, or significantly reduce, IT resources related to the mundane task of backup and allow your resources to be redeployed to more strategic projects. The cloud - can now be comfortable for you – with 100% recovery from anywhere all …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds