AfxGetMainWnd () call
Hi,
I`ve a CFormView in my SDI application as well as a dialog where the
user can change some settings to specific parts of the software. After
clicking on the "ok"-button I will create another dialog (CWaitDialog)
to verify all these settings the user has made.
I`m not sure if it is recommended to use the constructor to start this
dialog as well as the use of AfxGetMainWnd() (of course in the
mainthread). I`m not really sure in which situations it makes sense to
call such a global method.
CWaitDialog::CWaitDialog (BOOL pFlag, CString& pszCaption, CString&
pszText) : CDialog ()
{
m_pFlag = pFlag;
// Disable the main window and create the dialog.
AfxGetMainWnd ()->EnableWindow (FALSE);
Create (IDD_WAITDIALOG);
// Initialize the dialog caption and the static text control.
SetWindowText ((pszCaption.GetLength()) ? _T("Working") :
pszCaption);
// Display the dialog.
ShowWindow (SW_SHOW);
}
and here is my call of this dialog in the method OnWizardFinish()
which will be called if the user clicks the "ok" button to update his
settings.
void CWizardDialog::OnWizardFinish()
{
BOOL bContinue = TRUE;
BOOL stillWorking = TRUE;
CString dialogtitle ("Please wait...");
CString dialogtext ("Wait for me to do my stuff...");
CWaitDialog dlg (bContinue, dialogtitle, dialogtext);
while (stillWorking && bContinue)
{
//verify all data
//add message to dialog if verifcation failed (to inform the
user)
}
//finished
dlg.Close();
}
best regards
Hans