visual C++ 2010 MFC 不收缩隐藏那些不经常使用的菜单项

最近写了个小程序,用MFC向导生成了一个单文档模板,后添添改改做的,但是菜单项老师隐藏了,这点很不爽,google了一下,没结果,很多人问,查询了下MSDN,发现:

Remarks

 

The CMFCMenuBar class is a menu bar that implements docking functionality. It resembles a toolbar, although it cannot be closed - it is always displayed.

CMFCMenuBar supports the option of displaying recently used menu item objects. If this option is enabled, the CMFCMenuBar displays only a subset of the available commands on first viewing. Thereafter, recently used commands are displayed together with the original subset of commands. In addition, the user can always expand the menu to view all available commands. Thus, each available command is configured to display constantly, or to display only if it has been recently selected.

然后继续发现

 A pop-up menu can hide rarely used commands if it has a parent button and the parent window is derived from the CMFCMenuBar Class. Use CMFCMenuBar::SetRecentlyUsedMenus to enable this feature and CMFCMenuBar::IsRecentlyUsedMenus to determine if this feature is currently enabled. You must call both of these methods for the parent window.

心想,原来是这两个函数?果断在
 m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY /* & ~ AFX_CBRS_AUTOHIDE*/ );

下面添加
m_wndMenuBar.SetRecentlyUsedMenus(FALSE);
 m_wndMenuBar.SetShowAllCommands(TRUE);

这两行,发现运行了还是没效果呢,再朝下找找,发现

CList<UINT, UINT> lstBasicCommands;

 lstBasicCommands.AddTail(ID_FILE_NEW);
 lstBasicCommands.AddTail(ID_FILE_OPEN);
 lstBasicCommands.AddTail(ID_FILE_SAVE);
 lstBasicCommands.AddTail(ID_FILE_PRINT);
 lstBasicCommands.AddTail(ID_APP_EXIT);
 lstBasicCommands.AddTail(ID_EDIT_CUT);
 lstBasicCommands.AddTail(ID_EDIT_PASTE);
 lstBasicCommands.AddTail(ID_EDIT_UNDO);
 lstBasicCommands.AddTail(ID_APP_ABOUT);
 lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR);
 lstBasicCommands.AddTail(ID_VIEW_TOOLBAR);
 lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003);
 lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005);
 lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE);
 lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER);
 lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK);
 lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA);
 lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7);

 CMFCToolBar::SetBasicCommands(lstBasicCommands);

而这些后面不就是默认自带的菜单项么,查询了下 CMFCToolBar::SetBasicCommands ,MSDN显示:

Sets the list of commands that are always displayed when a user opens a menu. //当用户打开菜单时,设置永久显示的菜单列表

A basic command is always displayed when the menu is opened. This method is meaningful when the user chooses to view recently used commands. //当菜单打开时,一个基本命令将一直显示。这个方法在用户选择查看最近使用过的命令的时候非常有意义。

Use the CMFCToolBar::AddBasicCommand method to add a command to the list of basic commands. Use the CMFCToolBar::GetBasicCommands method to retrieve the list of basic commands that is used by your application.

See the Explorer sample for an example that uses this method.

不太明白什么意思,大致上是说用来显示最近的命令,注释掉看看,发现菜单伸缩的那个按钮没有了,搞定!



http://hi.baidu.com/lostmind/item/443b7d12f6335b0fb98a1a85

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值