|
Support
ActiveX / COM
Visual C++ / MFC
Customer Spotlight
Corporate Partners
Contact Sales
Call center available M-F 9:00 - 6:00 US Eastern Time. U.S. and Canada International Email |
Office Style Toolbar and Menu Customization
Author: Kirk Stowell
Posted: November 16, 2004
Environment: Visual C++ MFC
The following is a tutorial on how to create add customization to your applications toolbars and menus to your application. This tutorial assumes that you have already created an application that uses office style toolbars and menus. For a tutorial on how to create an application that uses Office style toolbars and menus, click here. Add customization for toolbars and menus.
MainFrm.cpp: BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) //{{AFX_MSG_MAP(CMainFrame) ON_WM_CREATE() //}}AFX_MSG_MAP ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize) END_MESSAGE_MAP() MainFrm.h: //{{AFX_MSG(CMainFrame) afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); //}}AFX_MSG afx_msg void OnCustomize(); DECLARE_MESSAGE_MAP() void CMainFrame::OnCustomize() { // Get a pointer to the Command Bar object. CXTPCommandBars* pCommandBars = GetCommandBars(); if(pCommandBars != NULL) { // Instantiate the customize dialog object. CXTPCustomizeSheet dlg(pCommandBars);
// Add the options page to the customize dialog. CXTPCustomizeOptionsPage pageOptions(&dlg); dlg.AddPage(&pageOptions);
// Add the commands page to the customize dialog. CXTPCustomizeCommandsPage* pCommands = dlg.GetCommandsPage(); pCommands->AddCategories(IDR_MDISAMTYPE);
// Use the command bar manager to initialize the // customize dialog. pCommands->InsertAllCommandsCategory(); pCommands->InsertBuiltInMenus(IDR_MDISAMTYPE); pCommands->InsertNewMenuCategory();
// Display the dialog. dlg.DoModal(); } } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { ...
// Load the previous state for toolbars and menus. LoadCommandBars(_T("CommandBars"));
return 0; } void CMainFrame::OnClose() { // Save the current state for toolbars and menus. SaveCommandBars(_T("CommandBars")); CMDIFrameWnd::OnClose(); }
See Also |


