-
April 11th, 2009, 05:13 AM
#1
Why does my property sheet has disappeared immediately?
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()
Code:
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:
Code:
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
Code:
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
Last edited by pcuong1983; April 11th, 2009 at 05:16 AM.
Reason: edit format
-
April 11th, 2009, 07:59 AM
#2
Re: Why does my property sheet has disappeared immediately?
The answer, why this happens, can be found in MSDN topic CWinThread::m_pMainWnd:
"The Microsoft Foundation Class Library will automatically terminate your thread when the window referred to by m_pMainWnd is closed. If this thread is the primary thread for an application, the application will also be terminated."
Main thread exists immediately after CExternalDataDlg dlg is closed.
The simplest way to fix this is to move CExternalDataDlg call to CImportPropertySheet ::OnInitDialog. If user presses Cancel, call EndDialog to prevent CImportPropertySheet from showing. In OnInitInstance, leave CImportPropertySheet as the only main application window.
-
April 11th, 2009, 08:15 AM
#3
Re: Why does my property sheet has disappeared immediately?
Originally Posted by Alex F
The answer, why this happens, can be found in MSDN topic CWinThread::m_pMainWnd:
"The Microsoft Foundation Class Library will automatically terminate your thread when the window referred to by m_pMainWnd is closed. If this thread is the primary thread for an application, the application will also be terminated."
Main thread exists immediately after CExternalDataDlg dlg is closed.
The simplest way to fix this is to move CExternalDataDlg call to CImportPropertySheet ::OnInitDialog. If user presses Cancel, call EndDialog to prevent CImportPropertySheet from showing. In OnInitInstance, leave CImportPropertySheet as the only main application window.
It works!
Thank so much
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|