CMDIFrameWndEx::OnShowMDITabContextMenu

Called by the framework before a shortcut menu is displayed on one of the tabs. Valid for MDI Tabbed Groups only.

virtual BOOL OnShowMDITabContextMenu(
   CPoint point,
   DWORD dwAllowedItems,
   BOOL bTabDrop 
);

Parameters

  • [in] point
    The location of the menu in screen coordinates.

  • [in] dwAllowedItems
    A bitwise-OR combination of flags that indicates what actions are allowed for the current tab:

    • BCGP_MDI_CREATE_VERT_GROUP - can create a vertical tab group.

    • BCGP_MDI_CREATE_HORZ_GROUP - can create a horizontal tab group.

    • BCGP_MDI_CAN_MOVE_PREV - can move a tab to the previous tab group.

    • BCGP_MDI_CAN_MOVE_NEXT - can move a tab to the next tab group.

    • BCGP_MDI_CAN_BE_DOCKED - switch a tabbed document to docked state (relevant for tabbed documents only).

  • [in] bTabDrop
    TRUE to display the menu as a result of dragging the tab onto another tabbed group. FALSE to display the menu as a shortcut menu on the currently active tab.

Return Value

Override this method in a CMDIFrameWndEx Class-derived class.

Remarks

If you do not process OnShowMDITabContextMenu, the shortcut menu will not be displayed. This function is generated by the MFC Application Wizard when you enable the MDI Tabbed Groups feature.

Example

The following example shows how OnShowMDITabContextMenu is used in the VisualStudioDemo Sample: MFC Visual Studio Application.

BOOL CMainFrame::OnShowMDITabContextMenu(CPoint point, DWORD dwAllowedItems, BOOL bDrop)
{
    CMenu menu;
    VERIFY(menu.LoadMenu(bDrop ? IDR_POPUP_DROP_MDITABS : IDR_POPUP_MDITABS));

    CMenu* pPopup = menu.GetSubMenu(0);
    ASSERT(pPopup != NULL);

    if ((dwAllowedItems & AFX_MDI_CREATE_HORZ_GROUP) == 0)
    {
        pPopup->DeleteMenu(ID_MDI_NEW_HORZ_TAB_GROUP, MF_BYCOMMAND);
    }

    if ((dwAllowedItems & AFX_MDI_CREATE_VERT_GROUP) == 0)
    {
        pPopup->DeleteMenu(ID_MDI_NEW_VERT_GROUP, MF_BYCOMMAND);
    }

    if ((dwAllowedItems & AFX_MDI_CAN_MOVE_NEXT) == 0)
    {
        pPopup->DeleteMenu(ID_MDI_MOVE_TO_NEXT_GROUP, MF_BYCOMMAND);
    }

    if ((dwAllowedItems & AFX_MDI_CAN_MOVE_PREV) == 0)
    {
        pPopup->DeleteMenu(ID_MDI_MOVE_TO_PREV_GROUP, MF_BYCOMMAND);
    }

    if ((dwAllowedItems & AFX_MDI_CAN_BE_DOCKED) == 0)
    {
        pPopup->DeleteMenu(ID_MDI_TABBED_DOCUMENT, MF_BYCOMMAND);
    }

    CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu;
    pPopupMenu->SetAutoDestroy(FALSE);
    pPopupMenu->Create(this, point.x, point.y, pPopup->GetSafeHmenu());

    return TRUE;
}

Requirements

Header: afxMDIFrameWndEx.h

See Also

Concepts

MFC Hierarchy Chart

Reference

CMDIFrameWndEx Class