How to close a dialog?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: How to close a dialog?

  1. #1
    Join Date
    Dec 2005
    Posts
    445

    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!!!

  2. #2
    Join Date
    Nov 2001
    Location
    Kerala,India
    Posts
    650

    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

  3. #3
    Join Date
    Dec 2005
    Posts
    445

    Re: How to close a dialog?

    Quote Originally Posted by Vinod S View Post
    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??

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,485

    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.

  5. #5
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,915

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center