MFC编程中,在显示主框架前先显示了一个登陆对话框,在登陆对话框中按确定时,我要将资源导入,但导入失败,我希望仍然只显示这个登陆对话框。原来我是这样做的:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
LoginDialog dlg; if(dlg.DoModal()==IDOK)
{
if (!((CDesignToolApp*)AfxGetApp())->LoadDataResources()) {
//CFrameWnd *pParentWnd = dlg.GetParentFrame();
//pParentWnd->SendMessage(WM_CREATE);
AfxMessageBox("资源导入失败");
return -1;
}
....
}
....
}
但这样就直接退出了。希望在资源导入失败后仍然只显示这个登陆对话框。
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
LoginDialog dlg; if(dlg.DoModal()==IDOK)
{
if (!((CDesignToolApp*)AfxGetApp())->LoadDataResources()) {
//CFrameWnd *pParentWnd = dlg.GetParentFrame();
//pParentWnd->SendMessage(WM_CREATE);
AfxMessageBox("资源导入失败");
return -1;
}
....
}
....
}
但这样就直接退出了。希望在资源导入失败后仍然只显示这个登陆对话框。
{
//.......
}
else
{
}
//------------------------------
else 什么不做就可以了..
void LoginDialog::OnOK()
{
....
if (!((CDesignToolApp*)AfxGetApp())->LoadDataResources()) {
//CFrameWnd *pParentWnd = dlg.GetParentFrame();
//pParentWnd->SendMessage(WM_CREATE);
AfxMessageBox("资源导入失败");
return;
}
CDialog::OnOK();
}