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.
有关的信息可以参考VisualStudioDemo Sample 例子,下面是例子截图:
MSDN上的例子为:
{
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 ;
}
然后在在MainFrm.h中,添加声明virtual BOOL OnShowMDITabContextMenu(CPoint point, DWORD dwAllowedItems, BOOL bDrop);即可。
其他资料:http://hi.baidu.com/20794027/blog/item/6cffdbdb3285c06ed0164ed2.html