RE: Closing All Open Dialogs
"SaranG(Saravanan)" wrote:
Hi all,
I am developing Dialog based application.This application
contains so many no. of dialogs. So i need to close all open dialogs
when i click the button in one dialog like named "Close All". I tried
with OnCancel and OnOK both this will close only one dialog of which i
called from. So any one can help me.
Thanks in advance,
SaranG.
Hi SaranG,
nomally I use for multiple dialoges the classes CPropertySheet /
CPropertyPage. I don't know if you do so. But I will explain you the way to
close the pages on the following sample.
CPropertySheet = parent
|
+-> CPropertyPage -> CPropertySheet = parent
| : |
+-> CPropertyPage .. +-> CPropertyPage ..
| : | :
+-> CPropertyPage .. +-> CPropertyPage ..
| : | :
/*==================================================
OnOK ( CPropertyPage )
==================================================*/
void CppXXXX::OnOK()
{
CPropertyPage::OnOK();
// On button OK send a close message to the parent
// ( CPropertySheet ) and let him close the childs
CWnd* pParentWnd = GetParent();
pParentWnd->SendMessage( WM_CLOSE, 0, (LPARAM)0 );
}
/*==================================================
OnOK ( CPropertySheet )
==================================================*/
void CpshXXXX::OnClose()
{
WORD i;
if( pDaten->m_pPropPages[i]->m_hWnd != NULL )
{ // send a close message to the child ( CPropertyPage )
for( i = 0; i < 3; i++ )
{ CWnd* pChildWnd = FromHandle( pDaten->m_pPropPages[i]->m_hWnd );
pChildWnd->SendMessage( WM_CLOSE, 0, (LPARAM)0 ); }
}
CPropertySheet::OnClose();
}
Continue this way until all your dialogues are closed. Also implement the
close for the cancel button.
Maybe it will help you.
Regards
werner m...