如何从父对话框关闭DoModal对话框及其所有子级 [英] How to close an DoModal dialog box and all its childs from the parent dialog box

查看:366
本文介绍了如何从父对话框关闭DoModal对话框及其所有子级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用4到5 DoModal对话框.但是,如果条件有任何变化,我想关闭DoModal对话框和所有子对话框,如果该domodal dilaog中的任何弹出窗口来自父dilaog.我已经使用了EndDialog函数.但是,如果该对话框中的任何弹出窗口仍然处于活动状态,则我也希望将其关闭.
在Advance中感谢

I am using 4 to 5 DoModal dialog box in my application . But if there is any change in the conditions i want to close the DoModal dialog and all the Child dialogs if any popup in this domodal dilaog from the parent dilaog. I have used the EndDialog function. But the Child dilaogs if any pop up in this Dialog remains active, i want to close them also.
thanks in Advance

推荐答案

有些父母也可以关闭其子成员... :)

Some parent could close its children members as well... :)

/*afx_msg for WM_CLOSE*/
void CParentDlg::OnClose()
{
  // CChildDlg CParentDlg::m_cChildAlert

  if (m_cChildAlert.GetSafeHwnd()) {
    m_cChildAlert.SendMessage(WM_COMMAND, IDCANCEL);
  }

  CDialog::OnClose();
}


这将严重滥用最初的UI原理. 不要这样做.

这样看:从运行父对话框启动子模态对话框时,直到子模态退出模态后,您才有权访问父对话框.不仅您没有办法关闭所有需要的内容,而且您无法访问父级.对话框只能堆叠一个.即使这是合法行为(与您想要的行为相反),这也是一种非常糟糕的风格.微软曾经在各种Windows设置对话框中设置2-3个级别,每个人都对此感到很开心.使用选项卡,启用/禁用屏幕的显示/隐藏部分,使用向导样式等,始终可以重新设计仅一个模式对话框的行为.

—SA
This would be a massive abuse of first UI principles. Don''t do it.

Look at this way: when you started a child modal dialog from running parent dialog, you don''t have access to the parent dialog until the child ends the modal state. Not only you don''t have a way to close all you need, you cannot access the parent. Dialogs can only stack one on top of the others. Even though this is legitimate behavior (in contrast to the one you want to have), this is a very bad style. Microsoft used to do 2-3 levels in all kind of Windows settings dialog, everyone made fun of it. It''s always possible to re-design be behavior of just the one modal dialog, using, say tabs, enable/disable show/hide parts of the screen, using wizard style, etc.

—SA


这篇关于如何从父对话框关闭DoModal对话框及其所有子级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆