Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1612929
  • 博文数量: 585
  • 博客积分: 14610
  • 博客等级: 上将
  • 技术积分: 7402
  • 用 户 组: 普通用户
  • 注册时间: 2008-05-15 10:52
文章存档

2013年(5)

2012年(214)

2011年(56)

2010年(66)

2009年(44)

2008年(200)

分类: C/C++

2012-01-27 02:55:55

 多文档的文档选项快捷菜单(vc2008sp1)
分类: 2.2 MFC9.0版本 241人阅读 评论(0) 收藏 举报

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.

有关的信息可以参考 例子,下面是例子截图:

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

阅读(737) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~