Contact Sales

Call center available M-F 9:00 - 4:00 US Eastern Time.

Case Studies

E.d. Soft

E.d. Soft selected Suite Pro with Visual Basic over many other...

Office Style Toolbars and Menus

Author: Kirk Stowell
Posted: November 16, 2007
Environment: Visual C++ MFC

The following is a tutorial on how to create an MDI application using the Visual Studio 6.0 Application Wizard that will have Office style menus and toolbars. The same technique can be used for later versions of Visual Studio .NET as well.

Create a simple MDI application using the MFC AppWizard:

  1. From Visual Studio and select ‘File’ then ‘New’ and select the ‘Projects’ tab.
  2. Choose MFC Appwizard(exe) as your project type and enter ‘MDISample’ as the project name.
  3. For the first step, make sure that "Multiple documents" is selected then press the ‘Finish’ button.

Add Command Bars components:

  1. Add the following line to your StdAfx.h file:

  2. Toolkit Pro users:

     #include <XTToolkitPro.h>; // Toolkit Pro components

    Command Bars users:

    #include <XTCommandBarsPro.h> // Command Bars components

     #include <XTCommandBarsPro.h>; // Command Bars components

  3. In your MainFrm.h file you need to change your base class to be CXTPMDIFrameWnd (CXTPFrameWnd for SDI applications):

  4.  class CMainFrame : public CXTPMDIFrameWnd




  5. If you plan to override either PreTranslateMessage or OnWndMsg make sure that you call the CXTPMDIFrameWnd base class, for example:

  6.  BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)


         // TODO: Add your specialized code here and/or call the base class


         return CXTPMDIFrameWnd::PreTranslateMessage(pMsg);



     BOOL CMainFrame::OnWndMsg(UINT message, WPARAM wParam,

                               LPARAM lParam, LRESULT* pResult)


         // TODO: Add your specialized code here and/or call the base class


         return CXTPMDIFrameWnd::OnWndMsg(message, wParam, lParam, pResult);


  7. Replace int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) function to

  8.  int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)


         if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)

             return -1;


         // Create Status bar.

         // Important: All control bars including the Status Bar

         // must be created before CommandBars....

         if (!m_wndStatusBar.Create(this) ||




             TRACE0("Failed to create status bar\n");

             return -1;      // fail to create



         // Initialize the Command Bar

         if (!InitCommandBars())

             return -1;


         // Get a pointer to the Command Bar object.

         CXTPCommandBars* pCommandBars = GetCommandBars();

         if(pCommandBars == NULL)


             TRACE0("Failed to create Command Bar object.\n");

             return -1;      // fail to create



         // Add the menu bar

         CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(

             _T("Menu Bar"), IDR_MDISAMTYPE);      

         if(pMenuBar == NULL)


             TRACE0("Failed to create menu bar.\n");

             return -1;      // fail to create



         // Create ToolBar

         CXTPToolBar* pToolBar = (CXTPToolBar*)

             pCommandBars->Add(_T("Standard"), xtpBarTop);

         if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME))


             TRACE0("Failed to create toolbar\n");

             return -1;



         // Set Office 2003 Theme



         return 0;


    Now we have an MDI application with an Office 2003's that Easy!

See Also