LAnnToolBar::FreeToolBarButtons

#include "ltwrappr.h"

virtual L_INT LAnnToolBar::FreeToolBarButtons(pButtons, uButtons)

Frees the memory allocated by LAnnToolBar::GetToolBarButtons for the pButtons array.

Parameters

pANNBUTTON pButtons

An array of ANNBUTTON structures that contain information about the buttons in the annotation toolbar.

L_UINT uButtons

Number of buttons in the toolbar. (Number of entries in the pButtons array.)

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

L_INT LAnnToolBar_FreeToolBarButtonsExample(LAnnToolBar annToolBar) 
{ 
   L_UINT uButtons; 
   pANNBUTTON pButtons; 
   L_INT nRet; 
   HGLOBAL hGlobal; 
   LBitmap myBitmap; 
 
   //Assume declaration: LAnnToolBar m_annToolBar 
 
   myBitmap.Load(MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\FadeMask.bmp"))); 
   myBitmap.Size(TOOLBARIMAGECX, TOOLBARIMAGECY); 
 
   // get the number of buttons in the toolbar  
   nRet = annToolBar.GetToolBarButtons(NULL,sizeof(ANNBUTTON), &uButtons); 
   if (nRet == SUCCESS) 
   { 
      // allocate an array big enough to  hold the number of existing buttons + 1  
      hGlobal = ::GlobalAlloc(GMEM_MOVEABLE, (uButtons+1)*sizeof(ANNBUTTON)); 
      pButtons = (pANNBUTTON)::GlobalLock(hGlobal); 
      if (pButtons) 
      { 
         // get the  existing buttons  
         nRet = annToolBar.GetToolBarButtons(pButtons,sizeof(ANNBUTTON),  &uButtons); 
         if (nRet ==  SUCCESS) 
         { 
            // add a new user defined tool button  
            pButtons[uButtons].uFlags = 0; 
            pButtons[uButtons].uTool = ANNTOOL_USER; 
            pButtons[uButtons].uBitmapStructSize=sizeof(BITMAPHANDLE); 
            pButtons[uButtons].pBitmapUp = myBitmap.GetHandle(); 
            pButtons[uButtons].pBitmapDown = pButtons[uButtons].pBitmapUp; 
            pButtons[uButtons].nToolTipTextID = -1; 
            pButtons[uButtons].pToolTipText = TEXT("Tool Tip"); 
            annToolBar.SetToolBarButtons(pButtons, uButtons+1); 
            // free uButtons  
            annToolBar.FreeToolBarButtons(pButtons, uButtons); 
 
            ::GlobalUnlock(pButtons); 
            ::GlobalFree(hGlobal); 
            //Change  the number of rows and columns  
            ANNTOOLBARINFO annToolBarInfo; 
            annToolBar.GetToolBarInfo(&annToolBarInfo, sizeof(annToolBarInfo)); 
            if(annToolBarInfo.uRows > 1) 
            { 
               annToolBar.SetToolBarColumns(annToolBarInfo.uColumns + 1); 
               //  or do the line below 
               //m_annToolBar.SetToolBarRows(annToolBarInfo.uRows -1); 
            } 
         } 
         else 
            AfxMessageBox(TEXT("Error getting toolbar buttons.")); 
      } 
      else 
         AfxMessageBox(TEXT("Not  enough memory to allocate pButtons.")); 
   } 
   else 
      AfxMessageBox(TEXT("Error getting  uButtons.")); 
 
   return SUCCESS; 
} 
Help Version 22.0.2021.9.12
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help