L_AnnFreeToolBarButtons

Summary

Frees the memory allocated by L_AnnGetToolBarButtons for the pButtons array.

Syntax

#include "l_bitmap.h"

L_LTANN_API L_INT L_AnnFreeToolBarButtons(pButtons, uButtons)

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

#define ANNTOOL_USER2 0x0101 
#include "windowsx.h" 
L_INT AnnFreeToolBarButtonsExample(L_HWND ToolbarWnd) 
{ 
   BITMAPHANDLE   LBitmap; 
   L_UINT         uButtons; 
   pANNBUTTON     pButtons; 
   L_INT          nRet; 
 
   nRet = L_LoadBitmap(MAKE_IMAGE_PATH("IMAGE1.CMP"), &LBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, 0, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   nRet = L_SizeBitmap(&LBitmap, TOOLBARIMAGECX, TOOLBARIMAGECY, 0); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   /* get the number of buttons in the toolbar */ 
   nRet = L_AnnGetToolBarButtons(ToolbarWnd, NULL, sizeof(ANNBUTTON), &uButtons); 
   if (nRet != SUCCESS) 
   { 
      _tprintf(_T("%s"), TEXT("Error getting buttons number.")); 
      return nRet; 
   } 
 
   /* allocate an array big enough to hold the number of existing buttons + 1 */ 
   pButtons = (pANNBUTTON)GlobalAllocPtr(GMEM_MOVEABLE, (uButtons + 1) * sizeof(ANNBUTTON)); 
   if (!pButtons) 
   { 
      _tprintf(_T("%s"), TEXT("Not enough memory to allocate pButtons.")); 
      return FAILURE; 
   } 
 
   /* get the existing buttons */ 
   for (L_UINT x = 0; x < uButtons + 1; x++) 
   { 
      pButtons[x].uStructSize = sizeof(ANNBUTTON); 
      pButtons[x].uBitmapStructSize = sizeof(BITMAPHANDLE); 
   } 
 
   nRet = L_AnnGetToolBarButtons(ToolbarWnd, pButtons, sizeof(ANNBUTTON), &uButtons); 
   if (nRet != SUCCESS) 
   { 
      _tprintf(_T("%s"), TEXT("Error getting toolbar buttons.")); 
      return nRet; 
   } 
 
   /* add a new user defined tool button */ 
   pButtons[uButtons].uFlags = 0; 
   pButtons[uButtons].uTool = ANNTOOL_USER2; 
   pButtons[uButtons].uToolCount = 0; 
   pButtons[uButtons].pBitmapUp = &LBitmap; 
   pButtons[uButtons].pBitmapDown = pButtons[uButtons].pBitmapUp; 
   pButtons[uButtons].nToolTipTextID = pButtons[uButtons-1].nToolTipTextID + 1; 
   pButtons[uButtons].pToolTipText = TEXT("D Tool"); 
 
   nRet = L_AnnSetToolBarButtons(ToolbarWnd, pButtons, uButtons + 1); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH("Result.BMP"), &LBitmap, FILE_BMP, 24, 0, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   L_FreeBitmap(&LBitmap); 
 
   /* free uButtons */ 
   nRet = L_AnnFreeToolBarButtons(pButtons, uButtons); 
 
   /* free pButtons */ 
   GlobalFreePtr(pButtons); 
   ShowWindow(ToolbarWnd, SW_SHOW); 
 
   return SUCCESS; 
} 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.