Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Adding/removing mdi tabs Collapse All
Subject Author Date
Raffaele Cappelli Feb 27, 2006 - 10:21 AM

In order to switch between tabbed interface and mdi interface at run time, I am using the following code:

void CMainFrame::MDITabsEnable(bool bEnable) {
    if (bEnable!=IsMDITabsEnabled()) {
        if (bEnable) {
            m_pMDITabs = new CExtTabMdiWnd();
            VERIFY(m_pMDITabs->Create(this));
            CWnd *pWnd = MDIGetActive();
            if (pWnd)
                MDIMaximize(pWnd);
        }
        else {
            m_pMDITabs->RemoveAllWndHooks();
            VERIFY(m_pMDITabs->DestroyWindow());
            m_pMDITabs->m_hWnd = NULL;
            delete m_pMDITabs;
            m_pMDITabs = NULL;
        }
        RecalcLayout();
    }
}

I obtained such code by try and error (in particular for the RemoveAllWndHooks() call); it seems to work, but maybe there is a simpler or better way, which I have not noted in the samples or in the help. Please let me know your advices.

Thank you.

Technical Support Feb 28, 2006 - 3:55 AM

Please take a look at the ProfStudio sample, which implements exactly what you need. Standard MDI (ID_UI_STD) and Tabbed MDI (ID_UI_TABBED) menu items in the View menu (accessible from the menu bar) allows you to switch the interface type on the fly. These menu commands are handled and updated in the CMainFrame::OnUiStd(), CMainFrame::OnUpdateUiStd(), CMainFrame::OnUiTabbed() and CMainFrame::OnUpdateUiTabbed() methods. The CProfStudioMdiTabSwitcher class implements the MDI tab control which is auto hidable when the interface is not tabbed (the OnTabWndSyncVisibility() virtual method does this work). The CProfStudioMenuControlBar class implements a menu bar which does not show document buttons when the interface is tabbed (the IsDisplayMdiDocumentButtons() virtual method does this work, all other methods are needed to make the menu bar not be able for re-docking like in Visual Studio .NET/2005). Both classes refer to the CMainFrame::m_bStandardMDI property which indicates the currently used interface type. This flag is also used in CMainFrame::PreTranslateMessage() for preventing the keyboard based activation of MDI child frame’s system menu and in the CMainFrame::OnPreparePopupMenu() handler method of the CExtPopupMenuWnd::g_nMsgPrepareMenu registered windows message for modifying some un-needed commands in the menu bar’s Windows menu when using the tabbed interface.

Raffaele Cappelli Mar 1, 2006 - 1:21 PM

It works very well, the only additional change I made with respect to your sample, was to override GetDetectedUiType(), to make dynamic control bars menu show "Tabbed document" or "MDI document" according to the current configuration.

Technical Support Mar 2, 2006 - 2:09 AM

Yes, your improvement is correct.

Raffaele Cappelli Mar 1, 2006 - 12:58 PM

Thank you very much, I missed that feature in the ProfStudio sample.