登陆框不出现...哪里错了
主界面IDD_MY000_DIALOG,在此基础上又插入了一个对话框Dialog1,作为登陆对话框IDD_DIALOG1。
怎么实现两个对话框的连接?就是启动时显示登陆框,判定密码正确后→确定→进入第一次编的那个界面?
BOOL CMy0000App::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls();// Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic();// Call this when linking to MFC statically
#endif
CMy0000Dlg dlg;
m_pMainWnd = &dlg;
int 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
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
CLoginDlg;《————这里看网上说都是CLoginDlg dlg;但是加了dlg报错!去掉了之后能运行但只出现主对话框,登陆框没出现
dlg.DoModal();
return FALSE;
}
D:\Program Files (x86)\Microsoft Visual Studio\MyProjects\0000\0000.cpp(75) : error C2371: 'dlg' : redefinition; different basic types
D:\Program Files (x86)\Microsoft Visual Studio\MyProjects\0000\0000.cpp(58) : see declaration of 'dlg'
[解决办法]
error C2371: 'dlg' : redefinition; different basic types
提示你了,dlg重定义不同类型。另外不要在Init里阻塞调用
[解决办法]
CLoginDlg;你这个登陆框都放在主对话框DoModal之后了,要放在主对话框DoModal之前来调用,并根据返回值来确定是否return FALSE