Guides & Tutorials (beta)

Add intelligent menus

by Kirk Stowell Visual C++ Created on 11/16/2007  |  Updated on 07/30/2024 0/5 ( 0 votes )

The following is a tutorial on how to add intelligent 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.

Create a simple MDI application using the MFC AppWizard:

  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 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.
    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();
    }
    

    Intelligent Menu

User Comments

No comments yet, sign in to comment.

Secure Transactions

Online transactions are secure and protected.


Ssl seal 1
This site is protected by Trustwave's Trusted Commerce program
CompliAssure Secured

Money Back Guarantee

If you are not 100% happy with your purchase within 30 days, you can return it for any reason. Your satisfaction is our priority!


Satisfication Guarantee

Contact sales@codejock.com for more details.