Guides & Tutorials (beta)

Upgrading Toolkit Standard to Toolkit Pro - Menubar Creation

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

You will have to change your existing code to use the pro version of menubars. Most applications that use the standard toolkit will reference CXTMenuBar object in CMainFrame::OnCreate. There the object m_wndMenuBar is created, and enable docking is called to dock the menubar to the applications work area. With the professional toolkit this is done somewhat differently and there is no need to call enable docking, for example:

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) ||
        !m_wndStatusBar.SetIndicators(indicators,
        sizeof(indicators)/sizeof(UINT)))
    {
        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
    }

    //  Remove the old menu bar code...
    //  if (!m_wndMenuBar.CreateEx(this, TBSTYLE_FLAT, 
    //    WS_CHILD | WS_VISIBLE | CBRS_TOP |
    //  CBRS_GRIPPER | CBRS_TOOLTIPS | 
    //    CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
    //      !m_wndMenuBar.LoadMenuBar(IDR_MAINFRAME))
    //  {
    //      TRACE0("Failed to create menubar\n");
    //      return -1;      // fail to create
    //  }

    //  m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
    //  EnableDocking(CBRS_ALIGN_ANY);
    //  DockControlBar(&m_wndMenuBar);

    return 0;
}

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.