I am not sure why check for valid password in OnInitDlg, while it seems that it should be checked before main dialog is invoked. No need for posting any messages to the thread. Besides, log in dialog should not be checked for cancel only but validate password and/or username. This code snippet shows how this can be done:
CLoginDlg loginDlg;
loginDlg.DoModal();
INT\_PTR nResponse = loginDlg.DoModal();
if(nResponse == IDCANCEL)
{
return FALSE; // canceled exit app, terminate
}
if(loginDlg.m\_csUser.CompareNoCase(lpszUser))
{
return FALSE; // no match exit app, terminate
}
if(loginDlg.m\_csPassword.Compare(lpszPassword))
{
return FALSE; // no match exit app, terminate
}
CMainDlg dlg;
m\_pMainWnd = &dlg;
INT\_PTR nResponse = dlg.DoModal();
.
.
.
JohnCz