vc6对话框应用程序

BOOLCPLC6100App::InitInstance(){AfxEnableControlContainer();//Standardinitialization/... BOOL CPLC6100App::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

CPLC6100Dlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
CMainDlg dlgMain;
dlgMain.DoModal();
}
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.
return FALSE;

}
为什么我的dlgMain对话框一闪就消失了,程序也就结束了
展开
 我来答
gis19831203
2011-10-18 · TA获得超过690个赞
知道小有建树答主
回答量:914
采纳率:0%
帮助的人:836万
展开全部
原因是你点CPLC6100Dlg的OK按钮时,对话框就退出了,紧接着主线程也退出了,所以你的dlgMain对话框就一闪而过了。
你可以把你的dlgMain和CPLC6100Dlg的关系互换一下,现在假设CPLC6100Dlg是你的dlgMain,这样做:
BOOL CPLC6100App::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
//看这里
CMainDlg dlg;
if(dlg.DoModal() != IDOK)
return false;

CPLC6100Dlg dlgMain;
m_pMainWnd = &dlgMain;
int nResponse = dlgMain.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.
return FALSE;

}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式