back,next and cancel

Posted on 2001-06-22
Last Modified: 2013-11-20
       I am trying to create a program that takes steps. How can I, when the user clicks the "Next >" button it opens another dialog and closes the one just used? And
when the user clicks the "Back >" button it opens previous dialog and closes the one just used? And cancel
would close all dialogs?
Question by:uma99
  • 4
  • 3
LVL 49

Expert Comment

ID: 6220325
What you want is called a "Wizard."  MFC supports this a a special case of what is called a CPropertySheet.  Real all about it:

In particular, you will need to call SetWizardMode() before calling DoModal();

-- Dan


Accepted Solution

Shielsy earned 50 total points
ID: 6220526
Create a base class (CWizardBaseDlg) for your dialogs (each page in wizard), which has a extra function called getButtonPressed(). This lets me know after the user has closed the dialog the next step to be taken. See then code below. Hope this helps.
     CWizardBaseDlg *paDlgs[3];

     paDlgs[0] =  new CWizard1Dlg();
     paDlgs[1] =  new CWizard2Dlg();
     paDlgs[2] =  new CWizard3Dlg();

     int iIndex = 0;
     int iRet = 0;

     while (true)

          iRet = paDlgs[iIndex]->getButtonPressed();
          if (iRet == CWizardBaseDlg::WIZ_BUTTON_CANCEL)

          else if (iRet == CWizardBaseDlg::WIZ_BUTTON_BACK)
          else if (iRet == CWizardBaseDlg::WIZ_BUTTON_OK)
               if (iIndex > 2)
     delete paDlgs[0];
     delete paDlgs[1];
     delete paDlgs[2];


Author Comment

ID: 6225136
Hi Shielsey
I looked at you answer it is fine if i am using just  3 or 4 dialogs but my apllication has 10 dialogs. You can view my apllication to be somewhat similar to those dialogs when ur installing an application.First of it has a splash screen then it asks the user to select options and later it stores the opetions in a drive an d somethinglike  that.'
Thank you if can suggest a remedy for this case.
but anyway i will try to use the one proposed by you.i am not sure of using base calss .so i will try to  use it thank you.
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

LVL 49

Expert Comment

ID: 6225352
You should use a Wizard-style PropertySheet.  It is designed to do *exactly* what you want to do.  Did you read my post?  Do you need additional details?

-- Dan

Author Comment

ID: 6225518
can youplease give me those aditonal details  . iam a new bie i do n ot know anything about property sheet and also i wnat to ask how to close all dialogs when you clickk on X
thaank you
LVL 49

Expert Comment

ID: 6226595
It really is quite simple.  Please read:

which explains it in detail and provides examples.  It boils down to...

CDlgPgWelcome pgWelcome; // a dlg box, but derived from CPropertyPage
CDlgPgStep1   pgStep1;  // also
CDlgPgStep2   pgStep2;  // also

CPropertySheet cSheet("ABC Install Wizard");

cSheet.AddPage( &pgWelcome );
cSheet.AddPage( &pgStep1 );
cSheet.AddPage( &pgStep2 );

int nRet= cSheet.DoModal();
if (nRet== IDOK ) {
   the user did not cancel from the wizard

This is a 50-point question that has already been locked, so I expect you to do a bit of research on your own.

-- Dan

Author Comment

ID: 6299102
Thank you Dan and Shielsy
LVL 49

Expert Comment

ID: 6307042
The pleasure is all mine.  I guess.

-- Dan

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 60
Need to retreive data from .TFS file exported by DVR 8 198
string initialization in java 11 113
tripleUp challenge 7 78
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question