Solved

back,next and cancel

Posted on 2001-06-22
8
185 Views
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?
0
Comment
Question by:uma99
  • 4
  • 3
8 Comments
 
LVL 49

Expert Comment

by:DanRollins
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:

http://msdn.microsoft.com/library/en-us/vcmfc98/html/_mfc_cpropertysheet.asp
and
http://msdn.microsoft.com/library/en-us/vccore98/HTML/_core_property_sheets.asp

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

-- Dan

0
 

Accepted Solution

by:
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.
Thanks,
Andy
     CWizardBaseDlg *paDlgs[3];

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

     int iIndex = 0;
     int iRet = 0;

     while (true)
     {
          paDlgs[iIndex]->DoModal();

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

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

0
 

Author Comment

by:uma99
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.
uma
0
 
LVL 49

Expert Comment

by:DanRollins
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
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:uma99
ID: 6225518
Dan,
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
button.'
thaank you
0
 
LVL 49

Expert Comment

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

  http://msdn.microsoft.com/library/en-us/vccore98/HTML/_core_property_sheets.asp

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 );
cSheet.SetWizardMode();

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

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
0
 

Author Comment

by:uma99
ID: 6299102
Thank you Dan and Shielsy
0
 
LVL 49

Expert Comment

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

-- Dan
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to know only "File created" with EventLog 3 32
matchUp  challenge 6 52
wait notify demo infinite loop 3 94
Sed question 2 68
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

943 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now