Partager via


CMDIFrameWndEx::EnableMDITabs

Enables or disables the MDI Tabs feature for the MDI frame window. When enabled, the frame window displays a tab for each MDI child window.

void EnableMDITabs(
   BOOL bEnable=TRUE,
   BOOL bIcons=TRUE,
   CMFCTabCtrl::Location tabLocation=CMFCTabCtrl::LOCATION_BOTTOM,
   BOOL bTabCloseButton=FALSE,
   CMFCTabCtrl::Style style=CMFCTabCtrl::STYLE_3D_SCROLLED,
   BOOL bTabCustomTooltips=FALSE,
   BOOL bActiveTabCloseButton=FALSE 
);

Parameters

  • bEnable
    Specifies whether tabs are enabled.

  • bIcons
    Specifies whether icons should be displayed on the tabs.

  • tabLocation
    Specifies the location of the tab labels.

  • bTabCloseButton
    Specifies whether to display tab close buttons.

  • style
    Specifies the style of tabs. Use STYLE_3D_SCROLLED for regular tabs or STYLE_3D_ONENOTE for Microsoft OneNote tabs.

  • bTabCustomTooltips
    Specifies whether custom tooltips are enabled.

  • bActiveTabCloseButton
    If TRUE, a Close button will be displayed on the active tab instead of on the right corner of the tab area.

Remarks

Call this method to enable or disable the MDI tabs feature for the MDI frame window. When enabled, all child windows are displayed as tabs.

The tab labels can be located at the top or bottom of the frame, depending on the setting of the parameter tabLocation. You may specify either CMFCTabCtrl::LOCATION_BOTTOM (the default setting) or CMFCTabCtrl::LOCATION_TOP.

If bTabCustomTooltips is TRUE, an AFX_WM_ON_GET_TAB_TOOLTIP message will be sent to the main frame window. Your code can handle this message and provide the framework with custom tooltips for MDI tabs.

Example

The following example shows how EnableMDITabs is used in the MDITabsDemo Sample: MFC Tabbed MDI Application.

void CMainFrame::UpdateMDITabs (BOOL bResetMDIChild)
{
    CMDITabInfo params;
    HWND hwndActive = NULL;

    switch (theApp.m_Options.m_nMDITabsType)
    {
    case CMDITabOptions::None:
        {
            BOOL bCascadeMDIChild = FALSE;

            if (IsMDITabbedGroup ())
            {
                EnableMDITabbedGroups (FALSE, params);
                bCascadeMDIChild = TRUE;
            }
            else if (AreMDITabs ())
            {
                EnableMDITabs (FALSE);
                bCascadeMDIChild = TRUE;
            }

            if (bCascadeMDIChild)
            {
                // CMDIClientAreaWnd m_wndClientArea
                hwndActive = (HWND) m_wndClientArea.SendMessage (WM_MDIGETACTIVE);
                m_wndClientArea.PostMessage (WM_MDICASCADE);
                m_wndClientArea.UpdateTabs( false );
                m_wndClientArea.SetActiveTab(hwndActive);
                ::BringWindowToTop (hwndActive);
            }
        }
        break;

    case CMDITabOptions::MDITabsStandard:
        hwndActive = (HWND) m_wndClientArea.SendMessage (WM_MDIGETACTIVE);
        m_wndClientArea.PostMessage (WM_MDIMAXIMIZE, LPARAM(hwndActive), 0L);
        ::BringWindowToTop (hwndActive);

        EnableMDITabs (TRUE,theApp.m_Options.m_bMDITabsIcons, theApp.m_Options.m_bTabsOnTop ? CMFCTabCtrl::LOCATION_TOP : CMFCTabCtrl::LOCATION_BOTTOM, theApp.m_Options.m_nTabsStyle);

        GetMDITabs().EnableAutoColor (theApp.m_Options.m_bTabsAutoColor);
        GetMDITabs().EnableTabDocumentsMenu (theApp.m_Options.m_bMDITabsDocMenu);
        GetMDITabs().EnableTabSwap (theApp.m_Options.m_bDragMDITabs);
        GetMDITabs().SetTabBorderSize (theApp.m_Options.m_nMDITabsBorderSize);
        GetMDITabs().SetFlatFrame (theApp.m_Options.m_bFlatFrame);
        GetMDITabs().EnableCustomToolTips (theApp.m_Options.m_bCustomTooltips);
        GetMDITabs().EnableCustomToolTips (theApp.m_Options.m_bCustomTooltips);
        GetMDITabs().EnableActiveTabCloseButton (theApp.m_Options.m_bActiveTabCloseButton);
        break;

Requirements

Header: afxMDIFrameWndEx.h

See Also

Reference

CMDIFrameWndEx Class

Hierarchy Chart