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 LToolbar::GetToolbarInfo. This function will update an LTOOLBARINFO structure with the current toolbar information.

The toolbar information can be changed using the LToolbar::SetToolbarInfo 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 LToolbar::Create.

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

The following example shows how create a user-defined toolbar:

/* This example will create an empty toolbar and then add four buttons*/ 
LToolbar tlb; 
L_INT ToolbarTest ( HWND hWnd ) 
{ 
   /*Assume that hWnd is a valid window handle*/ 
   /*Assume the following global declaration: */ 
   /*    LToolBar tlb; 
    
   /* Initiate the toolbar handle */ 
   tlb.Initialize () ; 
    
    
   /* Check the validity of the handle */ 
   if ( tlb.IsValid () ) 
   { 
      POINT pt = { 0, 0 } ; 
       
      /* Initiate the point will be used to align the toolbar at the top-left of its owner client area */ 
      ::ClientToScreen ( hWnd, &pt ) ; 
       
      /* Create the toolbar  */ 
      tlb.Create (hWnd, TEXT("Tools Window"), TOOLBAR_EMPTY ) ; 
      /* assume these resource IDs contain valid bitmaps */ 
      const L_INT nResId[ 4 ] = { IDB_BITMAP1, IDB_BITMAP2, IDB_BITMAP3, IDB_BITMAP4 }; 
      const L_TCHAR *szToolTipText[ 4 ] = { TEXT("Button 1"), TEXT("Button 2"), TEXT("Button 3"), TEXT("Button 4") }; 
      LBUTTONINFO ButtonInfo; 
       
      L_INT i; 
      L_UINT uRefId; 
      L_UINT32 dwFlags; 
       
      uRefId = 0;  /* we don't need a reference button when adding the first one */ 
      for( i = 0; i < 4; i++ ) 
      { 
         ButtonInfo.uID = i + 1; 
         ButtonInfo.hBitmap = LoadBitmap( 
         (HINSTANCE) GetWindowLong( hWnd /*hWndParent*/, GWL_HINSTANCE ), 
         MAKEINTRESOURCE( nResId[ i ] ) 
         ); 
         lstrcpy( ButtonInfo.szToolTipText, szToolTipText[ i ] ); 
         ButtonInfo.dwTag = 0L; 
         ButtonInfo.fsState = TBSTATE_ENABLED; 
          
         dwFlags = TOOLBAR_ADD_AFTER; 
         if( i == 0 || i == 2 ) 
            dwFlags |= TOOLBAR_ADD_TOOL; 
          
         tlb.AddButton(uRefId, &ButtonInfo, dwFlags ); 
          
         DeleteObject( ButtonInfo.hBitmap );  /* the toolbar toolkit keeps its own copy */ 
          
         uRefId = ButtonInfo.uID;  /* save last button ID */ 
      } 
       
      /* Set the toolbar position */ 
      tlb.SetPosition (&pt, TOOLBAR_POSITION_TOP | TOOLBAR_POSITION_LEFT ) ; 
       
      /* Show the toolbar */ 
      tlb.SetVisible (TRUE ) ; 
   } 
} 

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++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.