Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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
Posted
Updated 25-Jul-11 21:40pm
v2

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();
}
 
Share this answer
 
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
 
Share this answer
 
Comments
Richard MacCutchan 26-Jul-11 13:14pm    
Exactly right! +5
Sergey Alexandrovich Kryukov 26-Jul-11 13:28pm    
Thank you, Richard.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900