Articles and Tutorials

Upgrading Toolkit Standard to Toolkit Pro -
Add intelligent menus

Author: Kirk Stowell
Platform: Visual C++ MFC
  1. Add array of Ids that seem not very important for user.
    static UINT uHideCmds[] = 
    {
        ID_FILE_PRINT, ID_FILE_PRINT_PREVIEW, ID_WINDOW_CASCADE
    };
    
  2. Add to the CMainFrame::OnCreate Intelligent menu initialization:
    // Hide array of commands
    pCommandBars->HideCommands(uHideCmds, _countof(uHideCmds));
    
    // Set "Always Show Full Menus"; option to the FALSE
    XTP_COMMANDBARS_OPTIONS* pOptions = pCommandBars->GetCommandBarsOptions();
    pOptions->bAlwaysShowFullMenus = FALSE;
    
  3. Add LoadCommandBars(_T("CommandBars")); to the OnCreate function for CMainFrame. This will restore the previous state of your toolbar and menus plus any customization made.
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
        ...
     
        // Load the previous state for toolbars and menus.
        LoadCommandBars(_T("CommandBars"));
     
        return 0;
    }
    
  4. Add the OnClose message handler to CMainFrame and add SaveCommandBars(_T("CommandBars")); before the call to the base class. This will save the user's used commands.
    void CMainFrame::OnClose() 
    {
        // Save the current state for toolbars and menus.
        SaveCommandBars(_T("CommandBars"));
        CMDIFrameWnd::OnClose();
    }
    

    Expandable Menu

Articles and Tutorials