Re: AfxGetMainWnd () call
CWaitDialog::CWaitDialog (BOOL pFlag, CString& pszCaption, CString&
****
I'm curious why it isn't const CString & for the values; and why 'psz' si=
nce it is not a
pointer...
****>pszText) : CDialog ()
{
m_pFlag = pFlag;
// Disable the main window and create the dialog.
AfxGetMainWnd ()->EnableWindow (FALSE);
Create (IDD_WAITDIALOG);
****
This would be
Create(CWaitDialog::IDD);
and I note that you do not check the return value to see if it worked...
****
// Initialize the dialog caption and the static text control.
SetWindowText ((pszCaption.GetLength()) ? _T("Working") :
pszCaption);
****
That would be
SetWindowText(pszCaption.IsEmpty() ? _T("Working") : pszC=
aption);
****
// 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...");
****
Note that you should not include English words in literal strings in a pr=
ogram; it makes
localization very difficult.
****> CWaitDialog dlg (bContinue, dialogtitle, dialogtext);
while (stillWorking && bContinue)
{
//verify all data
//add message to dialog if verifcation failed (to inform th=
e
user)
}
****
There is something odd here; for example, why is the dialog allowed to be=
closed if the
data isn't valid? You should be verifying the data before you allow th=
e dialog to close!
I agree; but some data to verfiy will take some time - for example
verifying the network settings (ip-ping or searching for a dhcp
server); and both the dialog as well as verfiying the data will be in
the same thread.
Therefore maybe it`s ok to open the waitdialog for the user to verfiy
all his settings; but if these settings are not ok, then I will only
close the waitdialog so that the user can made some changes to fix
these errors.
best regards
Hans
I'd throw all this code out and start over. Do a modal dialog, don't l=
et it close until
the data is verified (don't even enable the OK button!)
joe
****
//finished
dlg.Close();
}
best regards
Hans
Joseph M. Newcomer [MVP]
email: newco...@flounder.com
Web:http://www.flounder.com
MVP Tips:http://www.flounder.com/mvp_tips.htm- Zitierten Text ausblenden =
-
- Zitierten Text anzeigen -