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

  • When individual departments procure cloud service for their own use, they usually don't consider the hazardous organization-wide implications. Read this paper to learn best practices for setting up an internal, IT-based cloud brokerage function that service the entire organization. Find out how this approach enables you to retain top-down visibility and control of network security and manage the impact of cloud traffic on your WAN.

  • U.S. companies are desperately trying to recruit and hire skilled software engineers and developers, but there is simply not enough quality talent to go around. Tiempo Development is a nearshore software development company. Our headquarters are in AZ, but we are a pioneer and leader in outsourcing to Mexico, based on our three software development centers there. We have a proven process and we are experts at providing our customers with powerful solutions. We transform ideas into reality.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date