المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Why does my property sheet has disappeared immediately?



C++ Programming
04-11-2009, 08:52 AM
I have a dialog based application named: basicreport
and created
one dialog called: CExternalDataDlg ,
3 property page called: CImportPage, COptionPage, CConfirmPage
and 1 property sheet named: CImportPropertySheet.

inside: BOOL CBasicReportApp::InitInstance()


BOOL CBasicReportApp::InitInstance(){
......
CExternalDataDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK

}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel

}
return FALSE;
}

CExternalDataDlg displayed correctly, worked fine!
I have change above code to:

BOOL CBasicReportApp::InitInstance(){
......
CImportPropertySheet importWizardSheet(_T("Import Spreadsheet Wizard"));
CImportPage importpage;
COptionPage optionpage;
CConfirmPage confirmpage;

importWizardSheet.AddPage(&importpage);
importWizardSheet.AddPage(&optionpage);
importWizardSheet.AddPage(&confirmpage);
importWizardSheet.SetWizardMode();


m_pMainWnd = &importWizardSheet;

INT_PTR nWizardResponse = importWizardSheet.DoModal();
if(nWizardResponse == ID_WIZFINISH){
AfxMessageBox(_T("Importing..........."));
}
else if(nWizardResponse == IDCANCEL){
AfxMessageBox(_T("Cancel"));
}
else{
}
return FALSE;
}

CImportPropertySheet displayed correctly, worked fine!
but when i combinated the both above into once. It looked like

CExternalDataDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
CImportPropertySheet importWizardSheet(_T("Import Spreadsheet Wizard"));
CImportPage importpage;
COptionPage optionpage;
CConfirmPage confirmpage;

importWizardSheet.AddPage(&importpage);
importWizardSheet.AddPage(&optionpage);
importWizardSheet.AddPage(&confirmpage);
importWizardSheet.SetWizardMode();

INT_PTR nWizardResponse = importWizardSheet.DoModal();
if(nWizardResponse == ID_WIZFINISH){
AfxMessageBox(_T("Importing..........."));
}
else if(nWizardResponse == IDCANCEL){
AfxMessageBox(_T("Cancel"));
}
else{
}
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
return FALSE;
}

// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;


The ExternalDataDlg displayed, when i press OK button on ExternalDataDlg the CImportPropertySheet blink and the immediately disappear without any action by user.

i dont know why? Please kindly advise