Initializing and Freeing Toolbars

LEADTOOLS accesses toolbars through the TOOLBARHANDLE structure. This structure provides a working area for the toolbar functions. The toolbar handle must be initialized before calling any of the toolbar functions. This is done using the LToolbar::Initialize function. The following example shows how to initialize the toolbar handle.

/* Global LEAD toolbar handle */ 
pTOOLBARHANDLE g_pLeadToolbar ; 
LToolbar tlb; 
L_INT ToolbarTest ( HWND hWnd ) 
{ 
   /* Initiate the toolbar handle */ 
   tlb.Initialize () ; 
   /* Check the validity of the handle */ 
   if ( tlb.IsValid () ) 
   { 
      POINT pt = { 0, 0 } ; 
      /* Initiate the point to 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_PAINT ) ; 
      /* Set the toolbar position */ 
      tlb.SetPosition (&pt, TOOLBAR_POSITION_TOP | TOOLBAR_POSITION_LEFT ) ; 
      /* Show the toolbar */ 
      tlb.SetVisible (TRUE ) ; 
   } 
   return SUCCESS ; 
} 

A toolbar handle is valid after LToolbar::Initialize has been called. However, LToolbar::Create must be called in order to call any other Toolbar functions. The validity of the toolbar should be checked before calling any other toolbar functions. This is done using LToolbar::IsValid.

When the TOOLBARHANDLE structure is no longer needed, it should be freed using the LToolbar::Free function. The following example shows how to free a toolbar handle:

LToolbar tlb; 
L_INT FreeToolbar () 
{ 
   if ( tlb.IsValid () ) 
   { 
      tlb.Free (); 
      return SUCCESS ; 
   } 
   else 
   { 
      return FAILURE ; 
   } 
} 

Once LToolbar::Free has been called, the toolbar handle is no longer valid.

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Toolbar C++ Class Library Help