Add a ON_COMMAND
for XTP_ID_CUSTOMIZE
to the message map for CMainFrame
. This will handle setup and display for the toolbar and menu customization dialog.
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(); }
User Comments
No comments yet, sign in to comment.