-
November 23rd, 2009, 06:25 AM
#1
How to close a dialog?
Gurus,
My main dialog creates a modal dialog which in turn creates another modal dialog when the user click on a button.
/////////////////////////////
// Main Dialog //
////////////////////////////
||
///////////////////////////
// Modal DLG 1 //
//////////////////////////
||
///////////////////////////
// Modal DLG 2 //
//////////////////////////
Code:
void CMyModalDlg1::OnBnClick()
{
CMyModalDlg2 ModalDlg2();
INT_PTR iResult = ModalDlg2.DoModal();
....
}
How can I close BOTH created modals from my main dialog ??
I've tried:
Code:
void CModalDlg1::CloseDialog()
{
EndDialog( 0 );
}
void CMainDlg::CloseBothDialogs()
{
if ( m_pModalDlg1 )
m_pModalDlg1->CModalDlg1();
}
ModalDlg1 is closed after calling CloseBothDialog() but it ModalDlg2 was created by Modal1, the dialog will not terminate.
Any advice??
Many thanks!!!
-
November 23rd, 2009, 08:15 AM
#2
Re: How to close a dialog?
Why dont you try sending message to your pop up windows Or communicate with them using any events or mutex and make them close by them selves. I dont know your senario well but this is a suggestion.
Do rate this post if it find useful to you
-
November 23rd, 2009, 09:11 AM
#3
Re: How to close a dialog?
Originally Posted by Vinod S
Why dont you try sending message to your pop up windows
The problem is that I don't know what is the hwnd of the new created modal until I call DoModal().
The problem is that DoModal() blocks so I can't get the hwnd anyway ...
Advice??
-
November 23rd, 2009, 10:29 AM
#4
Re: How to close a dialog?
Your code isn't clear. Please post the code that shows where the main dialog displays dialog1 and dialog2. Does dialog1 display dialog2? If so, display that code as well.
-
November 24th, 2009, 12:03 AM
#5
Re: How to close a dialog?
Besides all why would you want to close [b]modal dialog from any place?
Modal dialog disables main window and all popups. Modal is designed to collect data; user should decide when to close it and how (OK or Cancel).
If you use dialog to display status or progress, you should use modeless dialogs.
Another thing: why one modal dialog over another?
I think you should rethink your design or be clearer describing what you are trying do. Remember that nobody has a crystal ball.
There are only 10 types of people in the world:
Those who understand binary and those who do not.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|