Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hiercharcal dialog structures 1

Status
Not open for further replies.

ugly

Programmer
Joined
Jul 5, 2002
Messages
70
Location
GB
I am designing a small app that will be entirely dialog based. The app will consist of a shallow hierchary of screens, a login screen, leading to a main menu then a number of other screens accesable from the main menu dialog.
The idea I have is to have a series of MODAL dialogs, to navigate from one dialog to another you press a button which kills the present dialog (EndDialog) and then instantiates a instance of the next required screen and displays it. In effect this means that I am constantly creating , destroying, recreating dialogs . Is there a better way to do this??
 
It sounds like you're trying to create a wizard. Here's how to do that:

The base class for a wizard is called CPropertySheet. Derive a class from that and use that as your wizard "framework".

Each dialog in a wizard must be derived from CPropertyPage (which is in turn derived from CDialog). To make a wizard page, first create a dialog in the resource editor, then make a class for it using ClassWizard. Make sure this class derives from CPropertyPage instead of CDialog. Inside this class, you may need to override the following functions:

OnSetActive() => is similar to OnInitDialog()
OnWizardNext(), OnWizardBack(), OnWizardCancel(), OnWizardFinish() => called to notify you of the appropriate button presses

IMPORTANT: In order to show the appropriate combination of Back/Next/Finish buttons, you need to call CPropertySheet::SetWizardButtons(). A good place to do this is inside your OnSetActive override, like this:

Code:
BOOL CMyWizardPage::OnSetActive()
{
    //Do other initialization

    CMyWizardBase *parent=(CMyWizardBase *)GetParent();

    //Displays the back and next buttons
    //use PSWIZB_FINISH for the finish button
    parent->SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);

    //Finish initialization

    return CPropertyPage::OnSetActive();
}


Once you have all your classes, here's an example of how you would go about actually displaying the wizard:

Code:
CMyWizardBase wiz;
CMyWizardPage1 page1;
CMyWizardPage2 page2;

wiz.AddPage(&page1);
wiz.AddPage(&page2);

wiz.SetWizardMode();
wiz.DoModal();

HTH.
 
Many thanks for your help i will look into this
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top