Frees the memory allocated by LAnnToolBar::GetToolBarButtons for the pButtons array.
#include "ltwrappr.h"
virtual L_INT LAnnToolBar::FreeToolBarButtons(pButtons, uButtons)
An array of ANNBUTTON structures that contain information about the buttons in the annotation toolbar.
Number of buttons in the toolbar. (Number of entries in the pButtons array.)
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
Win32, x64.
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 Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document