SECToolBarManager::DefineDefaultToolBar

Define a customizable toolbar default state.

Defined in: tbarmgr.cpp

Syntax

DefineDefaultToolBar(UINT nID, const CString& strTitle, UINT nBtnCount, UINT* lpBtnIDs, DWORD dwAlignment, UINT nDockBarID, UINT nDockNextToID, BOOL bDocked, BOOL bVisible)

DefineDefaultToolBar(UINT nID, const CString& strTitle, UINT nToolbarID, UINT& nRetButtonCount, UINT*& pRetButtonArray, DWORD dwAlignment, UINT nDockBarID, UINT nDockNextToID, BOOL bDocked, BOOL bVisible)

Return Value

void

Parameters

nID

Id for this default toolbar window. Must be unique, and must be AFX_IDW_TOOLBAR+n, where n=0,4,5,... (1,2,3 will conflict with existing MFC resources)

strTitle

Default title text for this toolbar.

nBtnCount

Number of button ids in lpBtnIDs array. Use NUMELEMENTS macro for simplicity. (see below).

lpBtnIDs

Array of button ids defining the button order for this default configuration.

nToolbarID

The resource id of a toolbar to scan for building a default array

nRetButtonCount

The number of elements in nRetButtonArray

nRetButtonArray

An array of button ID's, allocated by the toolbar manager

dwAlignment

Alignment of this toolbar, choose from CBRS_ALIGN_* controlbar styles. Defaults to CBRS_ALIGN_ANY.

nDockBarID

Id of dockbar for initial dock. Can be AFX_IDW_DOCKBAR_TOP, AFX_IDW_DOCKBAR_RIGHT, AFX_IDW_DOCKBAR_LEFT, AFX_IDW_DOCKBAR_BOTTOM. Defaults to AFX_IDW_DOCKBAR_TOP.

nDockNextToID

If defined, this toolbar will dock in the column after the nDockNextToID parameter.

bDocked

If False, toolbar will be floating initially.

bVisible

If False, toolbar will initially be invisible

Comments

Use this function to set the initial state of 1 customizable toolbar. This initial state will be applied in response to a SECToolBarManager::SetDefaultDockState call. Typically this function is called in your CMainFrame::OnCreate handler.

Example

pToolBarMgr->DefineDefaultToolBar(
 AFX_IDW_TOOLBAR,
 _T("File"),
 NUMELEMENTS(fileButtons),
 fileButtons,
 CBRS_ALIGN_ANY,
 AFX_IDW_DOCKBAR_TOP);
Where,
static UINT BASED_CODE fileButtons[] =
{
ID_FILE_NEW,
ID_FILE_OPEN,
ID_FILE_SAVE,
ID_FILE_SAVEALL,
ID_SEPARATOR,
ID_EDIT_CUT,
ID_EDIT_COPY,
ID_EDIT_PASTE,
ID_EDIT_DELETE,
ID_SEPARATOR,
ID_FILE_PRINT,
ID_APP_ABOUT,
};
Alternatively, you can use a toolbar resource to define the grouping:
pToolBarMgr->DefineDefaultToolBar(
 AFX_IDW_TOOLBAR,
 _T("Default"),
 IDR_MAINFRAME,
 m_nDefButtonCount,
 m_pDefButtonArray,
 CBRS_ALIGN_ANY,
 AFX_IDW_DOCKBAR_TOP);
However, don't forget to delete m_pDefButtonArray in your destructor.
This eliminates the use of the static array.

See Also

SetDefaultDockState