Getting and Setting Toolbar Information

General information about a toolbar can be accessed through an LTOOLBARINFO structure. This includes information about the size of bitmaps used to display any associated buttons, the number of tools present on the toolbar, an array of structures that contain information about the individual tools on the toolbar and any user-defined information included in the toolbar. To get the current information about a toolbar, use the L_TBGetToolbarInfo. This function will update an LTOOLBARINFO structure with the current toolbar information.

The toolbar information can be changed using the L_TBSetToolbarInfo function. This may be used to modify an existing toolbar, or to set the information for a new toolbar created using the TOOLBAR_EMPTY flag in L_TBCreate.

When the toolbar information is no longer needed, it should be freed by calling L_TBFreeToolbarInfo.

The following example shows how create a user-defined toolbar (we have assumed that the toolbar handle is already initialized and the application instance has the necessary bitmaps and strings):

#define TOOL_BUTTONS_COUNT 5 
#define NUM_OF_TOOLS  1 
#define DEF_BITMAP_WIDTH  18 
#define DEF_BITMAP_HEIGHT  17 
LBUTTONINFO ButtonsInfo [ TOOL_BUTTONS_COUNT ] ; 
LTOOLBARTOOL ToolInfo ; 
LTOOLBARINFO ToolbarInfo ; 
L_INT i ; 
// initialize buttons information. 
for ( i = 0; i < TOOL_BUTTONS_COUNT; i ++ ) 
{ 
   ButtonsInfo[i].uStructSize = sizeof ( LBUTTONINFO ) ; 
   ButtonsInfo[i].uID = i ; 
   ButtonsInfo[i].fsState= TBSTATE_ENABLED ; 
   ButtonsInfo[i].hBitmap = LoadBitmap ( g_hInstance, 
   MAKEINTRESOURCE ( i ) ) ; 
   // Load the string resource with the button ID. 
   LoadString ( g_hInstance, 
   i, 
   ButtonsInfo[i].szToolTipText, 
   sizeof ( ButtonsInfo[i].szToolTipText ) ) ; 
    
   ButtonsInfo[i].dwTag = 0 ; 
} 
// initialize the tool information. 
ToolInfo.uStructSize = sizeof ( LTOOLBARTOOL ) ; 
ToolInfo.uButtonsCount = TOOL_BUTTONS_COUNT ; 
ToolInfo.pButtons = ButtonsInfo ; 
ToolInfo.dwTag = 0 ; 
//initialize the toolbar information. 
ToolbarInfo.uStructSize = sizeof ( LTOOLBARINFO ) ; 
ToolbarInfo.cxBitmapWidth = DEF_BITMAP_WIDTH ; 
ToolbarInfo.cyBitmapHeight = DEF_BITMAP_HEIGHT ; 
ToolbarInfo.uToolsCount = NUM_OF_TOOLS ; 
ToolbarInfo.pTools = &ToolInfo ; 
ToolbarInfo.dwTag = 0 ; 
// set the toolbar information. 
L_TBSetToolbarInfo ( pToolbar, &ToolbarInfo ) ; 

See Also

Changing the Toolbar State

Programming with LEADTOOLS Toolbars

Getting Started

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Toolbar C API Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.