多文档的文档选项快捷菜单(vc2008sp1)

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上的例子为:

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 ;
}

然后在在MainFrm.h中,添加声明virtual BOOL OnShowMDITabContextMenu(CPoint point, DWORD dwAllowedItems, BOOL bDrop);即可。

 

其他资料:http://hi.baidu.com/20794027/blog/item/6cffdbdb3285c06ed0164ed2.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值