Access modal dialogs from application handle
-
Okay this one is for the Gurus! I am trying to open multiple modal dialogs from a parent modal dialog. However, in modal dialogs only one child dialog can be opened at a time under a parent dialog. Therefore, I have to use the applications main window to have multiple modal dialogs opened and use a map to track which dialogs belong to the parent dialog. How can I get a handle or pointer to the childrens dialog windows to store them in my map (for the parent to track)? My goal is to close all the parent's children dialogs once the parent's has been closed. And also consistently close them out by calling theDlg->EndDialog(IDOK) when the parent dialog has been closed by clicking "OK" or theDlg->EndDialog(IDCANCEL) when the parent dialog has been closed by clicking "Cancel".
-
Okay this one is for the Gurus! I am trying to open multiple modal dialogs from a parent modal dialog. However, in modal dialogs only one child dialog can be opened at a time under a parent dialog. Therefore, I have to use the applications main window to have multiple modal dialogs opened and use a map to track which dialogs belong to the parent dialog. How can I get a handle or pointer to the childrens dialog windows to store them in my map (for the parent to track)? My goal is to close all the parent's children dialogs once the parent's has been closed. And also consistently close them out by calling theDlg->EndDialog(IDOK) when the parent dialog has been closed by clicking "OK" or theDlg->EndDialog(IDCANCEL) when the parent dialog has been closed by clicking "Cancel".
AeJai wrote:
I am trying to open multiple modal dialogs from a parent modal dialog
Multiple modal dialogs...so, which is active - there can only be one at a time. Also, once a modal dialog starts, the only way for it to communicate with its parent window is by exiting - it contains its own message loop rather than using its parent window's message loop.
AeJai wrote:
My goal is to close all the parent's children dialogs once the parent's has been closed
A parent window cannot be closed if it has spawned a modal dialog. Just don't do it - 'multiple modal dialogs' is really a synonym for 'modeless dialogs', IMO. You can close the child modeless dialogs by posting
WM_CLOSE
messages to them, IIRC. -
AeJai wrote:
I am trying to open multiple modal dialogs from a parent modal dialog
Multiple modal dialogs...so, which is active - there can only be one at a time. Also, once a modal dialog starts, the only way for it to communicate with its parent window is by exiting - it contains its own message loop rather than using its parent window's message loop.
AeJai wrote:
My goal is to close all the parent's children dialogs once the parent's has been closed
A parent window cannot be closed if it has spawned a modal dialog. Just don't do it - 'multiple modal dialogs' is really a synonym for 'modeless dialogs', IMO. You can close the child modeless dialogs by posting
WM_CLOSE
messages to them, IIRC.The reason the parent window can be closed is because its parent too is the main window's (i.e., (long)AfxGetMainWnd()->m_hWnd) as well as its children. This allows for all the modal dialogs to open and not continue in the code sequentially until OK or Cancel has been clicked. I need to open more dialogs from this parent dialog in order to compare and modify values (of the contents). I cannot use modeless dialogs because it continues computing without the user selecting OK or Cancel; it just creates the dialog and will create multiple dialogs of the same type or instance rather. I have been able to reactivate the dialog that has been opened already by using a PropertyFrame pointer. I cannot just close the dialogs via WM_CLOSE, but should prevent the parent dialog from closing as long as its children dialogs are opened. That too will be as difficult.