Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Toolkit User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

6.9 Using the Customizable Toolbar Classes

The following sections describe how to use customizable tooltips in your applications.

6.9.1 To incorporate customizable toolbars into your application

  1. Generate a skeletal application with toolbars using AppWizard.

    If you create a Do this
    MDI application Replace CMDIFrameWnd with SECMDIFrameWnd. Replace CMDIChildWnd with SECMDIChildWnd.
    SDI application Replace CFrameWnd with SECFrameWnd.
  2. Replace CToolBar or SECToolbar with SECCustomToolBar. ReplaceCStatusBar with SECStatusBar.

  3. Use the Microsoft Visual Studio toolbar resource editor to create a composite bitmap of all the toolbar buttons you want to use with any of the customizable toolbars as one resource. Do NOT put any button separators inside this toolbar resource. Specify every button command ID you want to associate with a bitmap in the resource editor.

  4. You can also create a copy of the previous resource and set a larger pixel height/width and redraw any bitmap images as you see fit. This is your large buttons resource. It is important that you maintain a 1-1 button ID mapping to the resource you created earlier. This is essentially a different view of the same data.

  5. In your CMainFrame constructor, create the SECToolBarManager object. Use the existing m_pControlBarManager member from the frame's base class. For example:

  6. In CMainFrame::OnCreate(), issue a call to LoadToolBarResource to load the resource(s) created earlier. If you're only using one resource, use the same resource ID twice. For example,

    m_pControlBarManager is declared as type SECControlBarManager so you must typecast to SECToolBarManager to access the specific member function mentioned above. For example,

  7. Create a button group. For example:

    See Section 6.9.4, "To implement button groups," for more information.

  8. In CMainFrame::OnCreate(), define default toolbar resources via the DefineDefaultToolBar() method. For example,


    Toolbar IDs AFX_IDW_TOOLBAR+1,+2,+3 are reserved by other MFC components, including the status bar, and cannot be used in this call. However, you can use +0, +4 and higher.

  9. If you do not plan to load toolbar states from persistent storage, call the toolbar manager's SetDefaultDockState() method to pre-load the default toolbars in your application. For example:

    See Section 6.9.7, "To use the button map," Section 6.9.22, "To save and restore customizable toolbars," and "Section 6.9.17, "To implement the toolbar customization dialog."

6.9.2 To implement toolbars with the flat cool look with a toolbar manager

In the OnCreate() method of your main frame class, call the EnableCoolLook() method of the toolbar manager. For example:

6.9.3 To implement toolbars with the flat cool look without a toolbar manager

  1. Generate a skeletal application with toolbars.

    If you create a Do this
    MDI application Replace CMDIFrameWnd with SECMDIFrameWnd.
    Replace CMDIChildWnd with SECMDIChildWnd.
    SDI application Replace CFrameWnd with SECFrameWnd.
  2. Replace CToolBar or SECToolbar with SECCustomToolBar and CStatusBar with SECStatusBar.

  3. Change the toolbar create syntax to that of the SECCustomToolBar create overload and specific the cool extended styles. For example:

6.9.4 To implement button groups

  1. Create the button group as a static array using the button control IDs defined with the associated bitmap resource in the Resource Editor. For example:

  2. In CMainFrame::OnCreate(), define the default toolbar using the DefineDefaultToolBar() method. For example:


    Toolbar Ids AFX_IDW_TOOLBAR+1,+2,+3 are reserved by other MFC components, including the status bar and cannot be used in this call. However, you can use +0, +4 and higher.

6.9.5 To use multiple toolbar bitmap resources with the toolbar manager

Use the SECToolBarManager::AddToolBarResource() method in conjunction with LoadToolBarResource(). For example:

6.9.6 To find a button on a customizable toolbar

  1. Obtain a pointer to the customizable toolbar. See Section 6.9.15, "To obtain a pointer to a specific customizable toolbar," for more information.

  2. For each customizable toolbar, use the GetBtnCount() method and the m_btns data member to access the button data.


    If your application contains the Customize dialog, you may have more than one copy of that button in existence.

    For example:

6.9.7 To use the button map

The button map maps specific button command IDs to non-standard toolbar buttons.

  1. Create a customizable toolbar that uses a toolbar manager. See Section 6.9.1 for more information.

  2. Create a button map in your frame class implementation file. For example:

  3. In the frame's OnCreate() method, provide a reference to the button map using the toolbar manager's SetButtonMap() method. For example,

6.9.8 To implement a text button

  1. Create a customizable toolbar that uses a toolbar manager. See Section 6.9.1, "To incorporate customizable toolbars into your application," for more information.

  2. Create a button map with a TEXT_BUTTON macro entry in your frame class implementation file. For example:

  3. In the frame's OnCreate() method, provide a reference to the button map using the toolbar manager's SetButtonMap() method. For example:

6.9.9 To implement a text button with styles

  1. Create a customizable toolbar that uses a toolbar manager. See Section 6.9.1, "To incorporate customizable toolbars into your application," for more information.

  2. Create a button map with a TEXT_BUTTON_EX macro entry in your frame class implementation file. For example:

  3. In the frame's OnCreate() method, provide a reference to the button map using the toolbar manager's SetButtonMap() method. For example:

6.9.10 To implement a combo button

  1. Create a customizable toolbar that uses a toolbar manager. See Section 6.9.1 for more information.

  2. Create a button map with a COMBO_BUTTON macro entry in your frame class implementation file. For example:

  3. In the frame's OnCreate() method, provide a reference to the button map using the toolbar manager's SetButtonMap() method. For example:

6.9.11 To implement a twopart button

  1. Create a customizable toolbar that uses a toolbar manager. See Section 6.9.1, "To incorporate customizable toolbars into your application," for more information.

  2. Create a button map with a TWOPART_BUTTON macro entry in your frame class implementation file. For example:

  3. In the frame's OnCreate() method, provide a reference to the button map using the SetButtonMap() method. For example:

6.9.12 To implement a bitmap button using styles

  1. Create a customizable toolbar that uses a toolbar manager. See Section 6.9.1, "To incorporate customizable toolbars into your application," for more information.

  2. Create a button map with a STD_BUTTON macro entry in your frame class implementation file. For example:

  3. In the frame's OnCreate() method, provide a reference to the button map using the SetButtonMap() method. For example:

6.9.13 To make a customizable toolbar dockable

When you define toolbars with the toolbar manager, specify the docking behavior as parameters in the DefineDefaultToolbar() method. For example:

6.9.14 To reposition customizable toolbars at run time

  1. Obtain a pointer to the customizable toolbar. See Section 6.9.15 and Section 6.9.16.

  2. After you identify a controlbar as a customizable toolbar, use the DockControlBarEx member of CFrameWnd to modify the position of the toolbar. For example:

6.9.15 To obtain a pointer to a specific customizable toolbar

Use the CFrameWnd::GetControlBar() method. Pass the ID of the toolbar you want to access as a parameter. For example,

6.9.16 To iterate the customizable toolbars

Use the m_listControlBars member of the SECFrameWnd or SECMDIFrameWnd class declared as a CPtrList to iterate through the configured controlbars of the frame window:

6.9.17 To implement the toolbar customization dialog

  1. Incorporate toolbars with a toolbar manager. See Section 6.9.1, "To incorporate customizable toolbars into your application," for more information.

  2. Create a handler method in which to instantiate the Customization dialog. For example:

  3. Within the handler, instantiate a property sheet of type SECToolBarSheet. For example:

  4. If you need a toolbar page that shows and hides toolbars, create a property page of type SECToolBarsPage. Then, add it to the property sheet after specifying the toolbar manager for the page. For example:

  5. If you need a toolbar command page to drag-and-drop additional buttons onto toolbars, create a property page of SECToolBarCmdPage. Specify the toolbar manager, define the button groups, and add the page to the property sheet. For example:

  6. You can add additional property pages to the property sheet. For example:

  7. To invoke the dialog, call the DoModal() method:

6.9.18 To invoke the toolbar customization dialog with a toolbar button

  1. Create a handler to create the toolbar Customize dialog. See Section 6.9.17, "To implement the toolbar customization dialog," for more information.

  2. Map a button event to an additional handler, which posts a message to the message queue to launch the toolbar Customization dialog. For example,

    Do not use SendMessage(). The button message handler must return prior to invoking the Customization dialog.

6.9.19 To hide and show customizable toolbars

  1. Obtain a pointer to the desired toolbar. See Section 6.9.15, "To obtain a pointer to a specific customizable toolbar," for more information.

  2. Use the CFrameWnd::ShowControlBar() method to show or hide the toolbar.

6.9.20 To set the docking order of customizable toolbars

Specify the docking order via the nDockNextToID parameter of DefineDefaultToolBar. Set the value of this ID to the previous toolbar in the docking order. Here is the complete prototype for the method:

6.9.21 To changing the font for text buttons

Use the static SECTBTextButton::SetTextFont() accessor method to reset the style before using the toolbar manager to create any customizable toolbars, preferably in your CMainFrame constructor. For example:

6.9.22 To save and restore customizable toolbars

Method 1: SECWorkspaceManagerEx

Implement the SECWorkspaceManagerEx to save the state of your toolbars, docking windows, and views. For more information, see SECWorkspaceManagerEx in the Objective Toolkit Class Reference.

Method 2: LoadBarState/SaveBarState

The LoadBarState()and SaveBarState() methods are members of the SECFrameWnd and SECMDIFrameWnd frame classes. For example:

Method 3: LoadState/SaveState

The LoadState()/SaveState() methods are members of SECToolbarManager. For example:

If you do not want to support toolbar persistence, you can use the SECToolBarManager::SetDockState() method directly to place default toolbars.

6.9.23 To draw owner-draw controls embedded in a vertically docked toolbar

In the appropriate SECWndBtn-derived class, override SetMode() and always pass FALSE through to the base implementation. For example:


Take a look at the Toolbar sample located in \Samples\Toolkit\MFC\Docking\Toolbar.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.