LAnnToolBar::FreeToolBarButtons

#include "ltwrappr.h"

virtual L_INT LAnnToolBar::FreeToolBarButtons(pButtons, uButtons)

pANNBUTTON pButtons;

/* array of buttons to include in the toolbar */

L_UINT uButtons;

/* number of buttons in the toolbar */

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

Parameter

Description

pButtons

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

uButtons

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

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Required DLLs and Libraries

LTANN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Win32, x64.

See Also

Functions:

LAnnotation::GetOptions, LAnnotation::SetOptions, LAnnToolBar::Create, LAnnToolBar::GetToolChecked, LAnnToolBar::SetToolChecked, LAnnToolBar::IsButtonVisible, LAnnToolBar::SetButtonVisible, LAnnToolBar::GetToolBarButtons, LAnnToolBar::SetToolBarButtons, LAnnToolBar::GetToolBarInfo, LAnnToolBar::SetToolBarColumns, LAnnToolBar::SetToolBarRows

Topics:

Annotation Functions: Working with the Toolbar

 

Implementing Annotations

 

Key Annotation Features

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
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].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;
}