visual C++ 2010 MFC 不收缩隐藏那些不经常使用的菜单项
2012-09-25 19:44
232 查看
最近写了个小程序,用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
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
相关文章推荐
- visual C++ 2010 MFC 不收缩隐藏那些不经常使用的菜单项
- 【MFC】Windows 用Visual studio 2010 编译出来的MFC 程序,在平板电脑上无法使用长按来弹出右击菜单
- Visual C++ 2010开发权威指南-3 MFC菜单编程(细部需参考相应章节)
- Sharepoint 2010 根据用户权限隐藏Ribbon菜单
- 如何减小 Visual C++ 2010 静态编译出的 MFC 可执行文件的大小
- PostQuitMessage(0)要慎用,经常会造成MFC程序退出时内存泄露,还是尽量使用MFC基类的退出函数比较好。
- MFC弹出菜单隐藏解决
- MFC菜单使用总结
- Visual C++ 6.0使用MFC获取网页内容
- 《Visual C++ 2010入门教程》系列二:安装、配置和首次使用VS2010
- Visual C++ 2010 MSXML使用示例
- Unity3d NGUI的使用(十)(UIPlay Animation制作隐藏显示菜单)
- Visual C++ 2010 Express下使用WTL
- 如何在MATLAB R2010a 中使用Visual C++ 2010编译器
- VC 2010 + MFC:自定义文档视图框架,去除新建、保存、打开等菜单功能,让文档程序个性化
- MFC不收缩隐藏不常用菜单项
- Windows 7下使用Visual C++ 2010编译Python的cx_Oracle库
- MFC使用自带的MSXML6.dll解析xml(开发环境vc2010)
- Visual C++ 2010 使用心得 和帮助文档问题
- Visual C++ 2008入门经典 第13章 使用MFC编写Windows程序