Gets the information for the specified toolbar button.
#include "ltwrappr.h"
L_INT LToolbar::GetButtonInfo (uButtonId, pButtonInfo, uStructSize)
Identifier that indicates the button for which to get the information.
Pointer to an LBUTTONINFO structure to be updated with the button information.
Size, in bytes, of the structure pointed to by pButtonInfo. Use sizeof(LBUTTONINFO).
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
To change the information on the specified toolbar button, call this function to get the current information. Change the information in pButtonInfo and then call LToolbar::SetButtonInfo.
When the toolbar button bitmap is no longer needed, you must free it using the Windows API function DeleteObject.
This example will display the tool tip text of each button in a toolbar.
L_INT LToolbar__GetButtonInfoExample( HWND hWnd, LToolbar* tlb)
{
UNREFERENCED_PARAMETER(hWnd);
L_INT nRet;
LTOOLBARINFO ToolbarInfo;
LBUTTONINFO ButtonInfo;
L_UINT i, j;
/* get toolbar info */
ToolbarInfo.uStructSize = sizeof( LTOOLBARINFO );
nRet = tlb->GetToolbarInfo(&ToolbarInfo, sizeof(LTOOLBARINFO) );
if(nRet != SUCCESS)
return nRet;
/* iterate through tools */
for( i = 0; i < ToolbarInfo.uToolsCount; i++ )
{
/* get the text */
for( j = 0; j < ToolbarInfo.pTools[ i ].uButtonsCount; j++ )
{
ButtonInfo.uStructSize = sizeof( LBUTTONINFO );
nRet = tlb->GetButtonInfo (ToolbarInfo.pTools[ i ].pButtons[ j ].uID, &ButtonInfo, sizeof(LBUTTONINFO));
if(nRet != SUCCESS)
return nRet;
MessageBox(NULL, ButtonInfo.szToolTipText, TEXT(""), MB_OK);
/* free the bitmap so we don't leak */
DeleteObject( ButtonInfo.hBitmap );
}
}
/* free the info structure */
nRet = tlb->FreeToolbarInfo (&ToolbarInfo);
if(nRet != SUCCESS)
return nRet;
return SUCCESS;
}