How to create MFC applications that do not have a menu bar in Visual C++(MFC单文档和多文档程序中去掉菜单栏)(转)
2008-06-11 13:06
621 查看
SUMMARY
loadTOCNode(1, 'summary');For most Windows-based applications, a menu bar is a part of the user interface. The menu bar provides a functionality summary for the person using the program. However, it is not required that every Windows-based application must contain a menu bar. This article describes how to create an MFC application that does not have a menu bar.
For Windows-based applications generated by AppWizard, the IDR_MAINFRAME menu resource is the standard menu resource for both SDI and MDI applications. It is the only menu resource for an SDI application. MDI applications contain additional menus for each type of MDI child window they support. Those menu resources are usually named IDR_xxxTYPE, where xxx is related to the name of the corresponding document type. Thus, creating an application with no menus is not as easy for an MDI application as for an SDI application. You basically have to modify all functions related to loading and switching menus.
MORE INFORMATION
loadTOCNode(1, 'moreinformation');Steps to Create SDI Application that Has No Menu Bar
loadTOCNode(2, 'moreinformation');1. | Generate an SDI application with AppWizard. Do not delete the IDR_MAINFRAME menu resource. If you have an application that was not generated with AppWizard, do not delete the corresponding main menu resource. Leaving the menu resource is required to avoid assertion failures in the MFC code. |
2. | To prevent the main application window from having a menu bar, delete the already loaded menu, and set the hMenu field of the CREATESTRUCT structure to NULL in the CFrameWnd::PreCreateWindow() function: [code] BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if(cs.hMenu!=NULL) { ::DestroyMenu(cs.hMenu); // delete menu if loaded cs.hMenu = NULL; // no menu for this window } return CFrameWnd::PreCreateWindow(cs); } [/code] |
Steps to Create MDI Application that Has No Menu Bar
loadTOCNode(2, 'moreinformation');1. | Generate an MDI application with AppWizard. Do not delete the IDR_MAINFRAME menu resource. If you have an application that was not generated with AppWizard, do not delete the corresponding main menu resource. Leaving the menu resource is required to avoid assertion failures in the MFC code. |
2. | Delete menu resources associated with MDI child windows (IDR_xxxTYPE). They are not used. By deleting them, you avoid a resource (memory) leak. |
3. | Override the PreCreateWindow() function for the CMainFrame class: [code] BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if(cs.hMenu!=NULL) { ::DestroyMenu(cs.hMenu); // delete menu if loaded cs.hMenu = NULL; // no menu for this window } return CMDIFrameWnd::PreCreateWindow(cs); } [/code] |
4. | Modify the code responsible for switching menus by overriding the LoadFrame() and OnCreateClient() methods of CMainFrame. This is necessary because MFC has already loaded and switched menus automatically. The following shows what must be done: [code] // Overridden method declarations for CMainFrame BOOL LoadFrame( UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = NULL, CCreateContext* pContext = NULL ); BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* /*pContext*/); // Overridden method declarations for CMainFrame BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) { return CFrameWnd::LoadFrame(nIDResource,dwDefaultStyle, pParentWnd,pContext); } BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* /*pContext*/) { return CreateClient(lpcs,NULL); } [/code] |
var kbSurvey = new MS.Support.Fms.Survey("fmsSurvey");
kbSurvey.isKBEmbedded = true;
kbSurvey.addSubmitField('REGIONID', 'zh-cn');
kbSurvey.addSubmitField('SITE', 'gn');
kbSurvey.addSubmitField('SURVEYSCID', 'sw;en;1361');
kbSurvey.addSubmitField('SURVEYID', '1361');
kbSurvey.addSubmitField('SURVEYNAME', '');
kbSurvey.addSubmitField('BROWSERLANGCODE', 'zh-cn');
kbSurvey.addSubmitField('SURVEYLANGCODE', 'en');
kbSurvey.addSubmitField('FMSURL', '%252fdefault.aspx%252fkb%252f131368%252fen-us%252f');
kbSurvey.parameters = ['kb','en-us','131368','','','','','','',''];
kbSurvey.maxKBsInCookie = '10';
kbSurvey.kbvisited = '';
相关文章推荐
- "HOW TO: Create a Smooth Progress Bar in Visual C# .NET"的学习笔记
- How to start a second thread in an MFC-based ActiveX control to fire events in Visual C++
- How to create a resizeable dialog box with scroll bars in Visual C++
- 已解决:无法连接到WMI提供程序。你没有权限或者该服务器无法访问/cannot connect to WMI provider. You do not have permission or the……
- 《Description of CWnd derived MFC objects and multithreaded applications in Visual C++》译文
- Unable to start debugging on the web server. You do not have permission to debug the application. The URL for this project is in
- How to create custom navigation menu in SharePoint with XML data source 使用XML数据源在SharePoint创建自定义导航菜单
- How to increment version information after each build in Visual C++
- How to Use MFC Tab Control in Developing VC++ Applications
- ONT-How to Create a Debug File in Shipping Execution (文档 ID 290432.1)
- 【Android】Do not requestWindow.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your th
- 已解决:无法连接到WMI提供程序。你没有权限或者该服务器无法访问/cannot connect to WMI provider. You do not have permission or the……
- How to fix the issue that GEM_HOME and/or GEM_PATH not set issue for rvm in mac version 10.12
- How to create simple web service in VS2010, NOT WCF service
- how to open property manager in Visual C++ 2010 express edition
- Cannot connect to WMI provider.You do not have permission or the server is unreachable.Note that you can only manager SQL Server 2005 and later version with SQL Server Configuration Manager.Invalid namespace [0x8004100e]
- How to embed Lua in C++ on Visual Studio
- How do I hide a menu item in the actionbar?
- How to create custom navigation menu in SharePoint with XML data source 使用XML数据源在SharePoint创建自定义导航菜单
- "Your computer could not be joined to the domain. You have exceeded the maximum number of computer accounts you are allowed to create in this domain. Contact your system administrator to have this limit reset or increased."