Guides & Tutorials (beta)

Upgrading Toolkit Standard to Toolkit Pro - Toolbar Creation

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

You will also need to change you code to use the pro version toolbars. As with the menubar, the toolbar object is usually created in CMainFrame::OnCreate and enable docking is called to dock the toolbar to the applications work area. The toolbar is created in a similar way to the menu bar with the addition of loading the toolbar resource, 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
    }

    // Create ToolBar
    CXTPToolBar* pToolBar = (CXTPToolBar*)
        pCommandBars->Add(_T("Standard"), xtpBarTop);
    if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME))
    {
        TRACE0("Failed to create toolbar\n");
        return -1;
    }

    //  Remove the old tool bar code...
    //  if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, 
    //        WS_CHILD | WS_VISIBLE | CBRS_TOP |
    //      CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | 
    //        CBRS_SIZE_DYNAMIC) ||
    //      !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
    //  {
    //      TRACE0("Failed to create toolbar\n");
    //      return -1;      // fail to create
    //  }
    //  m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    //  EnableDocking(CBRS_ALIGN_ANY);
    //  DockControlBar(&m_wndToolBar);</font>

    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.