Articles and Tutorials

Upgrading Toolkit Standard to Toolkit Pro -
Command Bar Initialization

Author: Kirk Stowell
Platform: Visual C++ MFC

Command Bar must be initialized prior to using them and, they must be created after all control bar objects (such as your status bar) have been created.  This is also a good place for you to set the theme for the Command Bar.  In the standard version you would call xtAfxData.bXPMode = true; to set the theme for the toolkit to Officexp.  In the professional version you have theme managers for each component.  This allows you to define your own theme or select from several pre defined themes in the toolkit.

The following is an example of how to initialize the control bars:

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
    }

    // Set Office 2003 Theme
    CXTPPaintManager::SetTheme(xtpThemeOfficeXP);</font>

    return 0;
}

Cool Menu Note:

It is no longer necessary to call InstallCoolMenus to initialize themed menus with command icons for your application.  This is done internally with the Command Bar theme manager.

Articles and Tutorials