MFC 下对话框依次显示问题

bgcelite 2011-04-01 06:54:33
BOOL CAppicationApp::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

CAppicationDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();

CApp app;
app.DoModal(); //请问一下此处为什么不弹出对话框,谢谢各位了

// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
...全文
116 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
quwei197874 2011-04-02
  • 打赏
  • 举报
回复
自己定义个消息,在里面CDiaDlg dia; dia.DoModal();就可以了.
zyrr159487 2011-04-02
  • 打赏
  • 举报
回复
如果这个CDiaDlg 有弹出的话,不妨将下面的也改成这个试试看,有没有弹出

CDiaDlg dia;
dia.DoModal(); // 当程序执行到这里时为什么没有弹出对话框,谢谢
bgcelite 2011-04-02
  • 打赏
  • 举报
回复
BOOL CDiaApp::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

CDiaDlg 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
}

CTempDialog dia;
dia.DoModal(); // 当程序执行到这里时为什么没有弹出对话框,谢谢

// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}

红色代码 2011-04-01
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 hbxstone99 的回复:]
DoModal是模态框。。
[/Quote]
正解.模态会阻塞,直到返回
看雪?你懂得...哈哈
wltg2001 2011-04-01
  • 打赏
  • 举报
回复
CApp app;
app.DoModal(); //请问一下此处为什么不弹出对话框,谢谢各位了
===========
CApp是一个对话框类吗?
King_hhuang 2011-04-01
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 bgcelite 的回复:]
在dlg.DoModal()中点击OK后执行app.DoModal(); 但是根本没有弹框程序就退出了
[/Quote]

你的CApp是基于对话框的吗,在资源中有添加这个对话框并关联类CApp吗
如果已经做过了你点击OK应该可以弹出
bgcelite 2011-04-01
  • 打赏
  • 举报
回复
在dlg.DoModal()中点击OK后执行app.DoModal(); 但是根本没有弹框程序就退出了
寒冰雪 2011-04-01
  • 打赏
  • 举报
回复
DoModal是模态框。。
King_hhuang 2011-04-01
  • 打赏
  • 举报
回复
因为你这个int nResponse = dlg.DoModal();
对话框没有销毁,程序停在这个地方了,你必须先关闭dlg,才会执行下面的

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧