Click here to Skip to main content
15,886,362 members
Articles / Desktop Programming / MFC
Article

MDI Windows Manager Dialog

Rate me:
Please Sign up or sign in to vote.
4.47/5 (13 votes)
29 Apr 2000 121.5K   2.7K   35   9
Implementing "Windows..." dialog
  • Download source files - 4.6 Kb
  • Download demo project - 36.5 Kb
  • Sample Image - WindowsManager.gif

    What's this?

    This article describes how to implement a Windows Manager dialog. It manages currently open windows (Activate, Save, Close, Tile, Cascade, Minimize).

    How to use it?

    1. Add to your CMainFrame a class member variable of type CMDIClient. A good practice is to keep the variables protected (or private).

    2. Then, within the OnCreate() handler, add the following code:

    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
        if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
           return -1;
    	
         // Subclass the MDI client window
         VERIFY(m_MDIClient.SubclassWindow(m_hWndMDIClient));
    
         return 0;
    }

    3. Copy to your project the provided IDD_WINDOW_MANAGE dialog resource (from WindowManager.rct).

    4. Add the following resource strings:

    ID Caption Description
    IDS_WINDOW_WINDOWS "&Windows..." Menu text
    ID_WINDOW_MANAGE "Manages the currently open windows.\nWindows List" Message prompt

    5. Add a handler to command ID_WINDOW_MANAGE and add the following code.

    void CMainFrame::OnWindowManage()
    {
        m_MDIClient.ManageWindows(this);
    }

    6. Build and run your application.

    7. Go to Window menu and click on "Windows..."

    Unicode?

    Unicode has not been tested, but it should work.

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    Written By
    United States United States
    This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

    Comments and Discussions

     
    GeneralUseful example for improving MFC knowledge Pin
    Raymond_Gimilio26-Feb-07 7:32
    Raymond_Gimilio26-Feb-07 7:32 
    GeneralRe: Useful example for improving MFC knowledge [modified] Pin
    Ivan Zhakov26-Feb-07 7:58
    Ivan Zhakov26-Feb-07 7:58 
    GeneralWindow manager conflicts with tab control... Pin
    atali21-Oct-04 5:52
    atali21-Oct-04 5:52 
    I'm using this window manager with MDI tabbed interface from Dundas. They both are in same MFCext.dll - a separate project in VC++ 6.0 that I use as a snippet collection from CodeProject etc, so I don't have to put all components from here into every project I have. Now to the problem: This idea of having m_MDIClient member and subclassing it confuses the tab control code.

    Tab control related code in CMainFrame.OnCreate() :
    VERIFY(m_MTIClientWnd.Attach(this)); <-- fails with some assert

    The easy workaround I found was to delete the whole CMDIClient thing and add a single message handler to CMainFrame to process the Window->Manage message. Code for the message handler is an one-liner:

    void CMainFrame::OnWindowManage()
    {
    CWindowDlg(this).DoModal();
    }

    Works for me, may work for you...
    QuestionHow to add list of Documents as Tree Items??? Pin
    mahatma_cis5-Aug-04 3:23
    mahatma_cis5-Aug-04 3:23 
    Generalquestion Pin
    lequang17-Sep-03 20:31
    lequang17-Sep-03 20:31 
    Generaltree Pin
    yaser30-Aug-02 10:42
    yaser30-Aug-02 10:42 
    GeneralFit a dialog in a View of a Window Pin
    17-Apr-02 8:55
    suss17-Apr-02 8:55 
    GeneralRe: Fit a dialog in a View of a Window Pin
    Jim Busse13-Nov-02 10:27
    Jim Busse13-Nov-02 10:27 
    GeneralHorizontal Scroll Bar Pin
    G Poulose1-May-00 18:45
    G Poulose1-May-00 18:45 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.