Getting and Setting Toolbar Button Information

A toolbar can be changed by changing the buttons that make up that toolbar. LEADTOOLS provides several functions for getting and setting information about toolbar buttons.

General information about toolbar buttons can be accessed through an LBUTTONINFO structure, including button identifier, the state of the button, the bitmap used to display the button, the tool tip text displayed when the user places the mouse over the button and user-defined information included about the button. To get the current information on a specific button, call L_TBGetButtonInfo. To alter the information about a specific button uses the L_TBSetButtonInfo function.

Only one button can be selected or checked at a time. The selected button is the active button of the toolbar. To determine the current selected button of a toolbar, call L_TBGetButtonChecked. To set a different button as the selected button use L_TBSetButtonChecked.

In order to be selected, a toolbar button must be enabled. To determine if a specific button is enabled, call L_TBIsButtonEnabled. To enable or disable a button, use L_TBSetButtonEnabled.

Toolbar buttons may be visible or hidden. The visibility of a button may be changed using L_TBSetButtonVisible. To determine a button's current visibility status all L_TBIsButtonVisible.

The following example determines the button's visibility status and then toggles it.

L_INT ToggleToolbarButton ( pTOOLBARHANDLE pLeadToolbar, L_UINT uButtonID ) 
{ 
   if (SUCCESS == L_TBIsValid ( pLeadToolbar ) ) /* check the validity of the toolbar handle */ 
   { 
      L_BOOL fVisible ; 
      /* Get the state of the toolbar button visibility */ 
      L_TBIsButtonVisible( pLeadToolbar, uButtonID, &fVisible ) ; 
      if ( fVisible ) 
      { 
         /* Hid the button */ 
         L_TBSetButtonVisible ( pLeadToolbar, uButtonID, FALSE ) ; 
      } 
      else 
      { 
         /* Show the button */ 
         L_TBSetButtonVisible ( pLeadToolbar, uButtonID, TRUE ) ; 
      } 
       
      return SUCCESS ; 
   } 
   else 
   { 
      return FAILURE ; 
   } 
} 

In addition, buttons can be added or removed from a toolbar using L_TBAddButton and L_TBRemoveButton.

See Also

Changing the Toolbar Button State

Programming with LEADTOOLS Toolbars

Getting Started

Help Version 22.0.2022.12.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 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.