Making Modless Dialog Reappear After Exit Box Click - Programmer

This is a discussion on Making Modless Dialog Reappear After Exit Box Click - Programmer ; I have implemented a dockable modeless dialog using CSizingControlBar available at: http://www.codeguru.com/Cpp/W-D/dock...icle.php/c1455 The class derived from CSizingControlBar is instantiated as a member of the main window as is usually the case. But instead of executing the code to make the ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Making Modless Dialog Reappear After Exit Box Click

  1. Making Modless Dialog Reappear After Exit Box Click

    I have implemented a dockable modeless dialog using CSizingControlBar available at:
    http://www.codeguru.com/Cpp/W-D/dock...icle.php/c1455

    The class derived from CSizingControlBar is instantiated as a member of the main window as is usually the case. But instead of executing the code to make the window visible and dockable in the CMainFrame::OnCreate() method, I do this in a menu handler so it appears when the user commands it to.

    This dialog has and Exit Box in the title bar. (This is the X box usually in the upper right corner of the window used to close the window.) After this Exit Box is clicked on, and the window disappears, I want to be able to make this dialog reappear when the user commands it using the menu item again. I cannot make it reappear. I need help doing this.

    I know that when the user clicks on the Exit Box the handle remains valid as indicated by the IsWindow() function. I use this to tell if the user has already opened this dialog. Pasted below is the menu item handler that opens the dialog that I want also to reopen the dialog. The code that is branched to when IsWindow( ) returns true is my attempt to make the window reappear after the user has clicked on the Exit Box. None of the functions in this section of code work to make it reappear. Putting a call to Create() in this section causes an assertion failure because m_wndProjectView.m_hWnd isn't NULL. What is the right way to make this window reappear? What does clicking on the Exit Box do to the window to make it dissappear?

    void CMainFrame::OnViewProjectview()
    { if( IsWindow( m_wndProjectView.m_hWnd ) )
    { // None of the function calls in this branch works to make the dialog reappear.
    // They were added and tested one at a time.
    m_wndProjectView.BringWindowToTop();
    m_wndProjectView.ShowWindow( SW_SHOWNORMAL ); //SW_RESTORE was also passed and did not work

    m_wndProjectView.EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndProjectView, AFX_IDW_DOCKBAR_RIGHT );

    }else
    { m_bProjectViewCreated = m_wndProjectView.Create
    ( _T("Project View"), this, CSize(200, 100), TRUE /*bHasGripper*/, IDD_PROJECT_VIEW
    );
    if( m_bProjectViewCreated )
    { m_wndProjectView.SetBarStyle
    ( m_wndProjectView.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC
    );
    m_wndProjectView.EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndProjectView, AFX_IDW_DOCKBAR_RIGHT );
    }else
    { TRACE0("Failed to create Project View dialog bar\n");
    }
    }
    }


  2. Re: Making Modless Dialog Reappear After Exit Box Click

    I have found the answer. It is the function ShowControlBar(). The code is pasted below:

    void CMainFrame::OnViewProjectview()
    { if( IsWindow( m_wndProjectView.m_hWnd ) )
    { m_wndProjectView.m_pDockSite->ShowControlBar( &m_wndProjectView, TRUE, FALSE );
    }else
    { m_bProjectViewCreated = m_wndProjectView.Create
    ( _T("Project View"), this, CSize(200, 100), TRUE /*bHasGripper*/, IDD_PROJECT_VIEW
    );
    if( m_bProjectViewCreated )
    { m_wndProjectView.SetBarStyle
    ( m_wndProjectView.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC
    );
    m_wndProjectView.EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndProjectView, AFX_IDW_DOCKBAR_RIGHT );
    }else
    { TRACE0("Failed to create Project View dialog bar\n");
    }
    }
    }

    class CMainFrame : public CMDIFrameWnd
    { ...
    public:
    CProjectView m_wndProjectView;
    ...
    };

    class CProjectView : public CSizingControlBar
    { ...
    };
    "Artist" wrote in message news:HoqdnQ7DPM_maFPZnZ2dnUVZ_vqdnZ2d@speakeasy.ne t...
    I have implemented a dockable modeless dialog using CSizingControlBar available at:
    http://www.codeguru.com/Cpp/W-D/dock...icle.php/c1455

    The class derived from CSizingControlBar is instantiated as a member of the main window as is usually the case. But instead of executing the code to make the window visible and dockable in the CMainFrame::OnCreate() method, I do this in a menu handler so it appears when the user commands it to.

    This dialog has and Exit Box in the title bar. (This is the X box usually in the upper right corner of the window used to close the window.) After this Exit Box is clicked on, and the window disappears, I want to be able to make this dialog reappear when the user commands it using the menu item again. I cannot make it reappear. I need help doing this.

    I know that when the user clicks on the Exit Box the handle remains valid as indicated by the IsWindow() function. I use this to tell if the user has already opened this dialog. Pasted below is the menu item handler that opens the dialog that I want also to reopen the dialog. The code that is branched to when IsWindow( ) returns true is my attempt to make the window reappear after the user has clicked on the Exit Box. None of the functions in this section of code work to make it reappear. Putting a call to Create() in this section causes an assertion failure because m_wndProjectView.m_hWnd isn't NULL. What is the right way to make this window reappear? What does clicking on the Exit Box do to the window to make it dissappear?

    void CMainFrame::OnViewProjectview()
    { if( IsWindow( m_wndProjectView.m_hWnd ) )
    { // None of the function calls in this branch works to make the dialog reappear.
    // They were added and tested one at a time.
    m_wndProjectView.BringWindowToTop();
    m_wndProjectView.ShowWindow( SW_SHOWNORMAL ); //SW_RESTORE was also passed and did not work

    m_wndProjectView.EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndProjectView, AFX_IDW_DOCKBAR_RIGHT );

    }else
    { m_bProjectViewCreated = m_wndProjectView.Create
    ( _T("Project View"), this, CSize(200, 100), TRUE /*bHasGripper*/, IDD_PROJECT_VIEW
    );
    if( m_bProjectViewCreated )
    { m_wndProjectView.SetBarStyle
    ( m_wndProjectView.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC
    );
    m_wndProjectView.EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndProjectView, AFX_IDW_DOCKBAR_RIGHT );
    }else
    { TRACE0("Failed to create Project View dialog bar\n");
    }
    }
    }


+ Reply to Thread