How to delete the default button in CPropertySheet Wizard MFC application?

1.9k views Asked by At

Hey guys..I am designing a set-up wizard using CPropertySheet and CpropertyPage in MFC application...I have completed the design but the thing is..In normal CProperty Sheet there are four default buttons "BACK NEXT FINISH HELP"...but I want only NEXT and FINISH buttons ...I used the following code to do that but its giving me a run time error.stating.."stack overflow" I am not sure where exactly to include this code(i mean in which class)..nor how to utilize this function.. can any one help me..

BOOL CExtractorFinalUIDlg::OnSetActive() { CSelfExtractor setButtons = (CSelfExtractor)GetParent(); setButtons->SetWizardButtons(PSWIZB_NEXT | PSWIZB_FINISH | PSWIZB_CANCEL);

return CExtractorFinalUIDlg::OnSetActive();

}

2

There are 2 answers

0
dwo On BEST ANSWER

In the constructor of your propertysheet, insert

m_psh.dwFlags |= PSH_NOAPPLYNOW;

The m_psh is of type PROPSHEETHEADER, you can set a lot of things.

0
sbecker On

The actual cause of the stack overflow is that you call CExtractorFinalUIDlg::OnSetActive() in the CExtractorFinalUIDlg::OnSetActive(). So the function calls itself recursively. This leads to the stack overflow.

The function could be something like:

BOOL CExtractorFinalUIDlg::OnSetActive() {
     CPropertySheet* sheet = (CPropertySheet*) GetParent();
     ASSERT(sheet);
     // Combination of PSWIZB_NEXT and PSWIZB_FINISH might be useless
     sheet->SetWizardButtons(PSWIZB_NEXT | PSWIZB_FINISH | PSWIZB_CANCEL)

     return CPropertyPage::OnSetActive();
}

Look up MSDN: CPropertySheet::SetWizardButtons for more infos.