Specifies the callback function that will be used to notify the user about the toolbar events.
#include "LtTLB.h"
L_LTTLB_API L_INT L_TBSetCallback(pToolbar, pCallback, pUserData)
Pointer to a toolbar handle.
Optional callback function for additional processing. If you do not provide a callback function, use NULL as the value of this parameter. If you do provide a callback function, use the function pointer as the value of this parameter. The callback function must adhere to the function prototype described in the TOOLBARCALLBACK function.
Void pointer that you can use to pass one or more additional parameters that the callback function needs.
To use this feature, assign a value to a variable or create a structure that contains as many fields as needed. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID *
. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure.
If the additional parameters are not needed, pass NULL in this parameter.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes |
To determine the current callback function used to notify the user of toolbar events, call L_TBGetCallback.
LTTLB
For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.
This example will create a toolbar, set its callback and then use some of its button messages to display messages to the user.
L_INT EXT_CALLBACK LeadToolbarProc(pTOOLBARHANDLE pToolbar,
TOOLBARBUTTONID nButtonID,
L_UINT32 dwData,
L_VOID * pUserData)
{
UNREFERENCED_PARAMETER(pToolbar);
UNREFERENCED_PARAMETER(dwData);
switch ( nButtonID )
{
case ID_TOOL_PAINT_BRUSH:
MessageBox ( * ( HWND * ) pUserData, TEXT("BRUSH"), TEXT("Toolbar Message"), MB_OK ) ;
break ;
case ID_TOOL_PAINT_SHAPE_LINE:
MessageBox ( * ( HWND * ) pUserData, TEXT("LINE"), TEXT("Toolbar Message"), MB_OK ) ;
break ;
case ID_TOOL_PAINT_REGION_RECT:
MessageBox ( * ( HWND * ) pUserData, TEXT("RECT"), TEXT("Toolbar Message"), MB_OK ) ;
break ;
case ID_TOOL_PAINT_FILL_SURFACE:
MessageBox ( * ( HWND * ) pUserData, TEXT("SURFACE"), TEXT("Toolbar Message"), MB_OK ) ;
break ;
case ID_TOOL_PAINT_TEXT:
MessageBox ( * ( HWND * ) pUserData, TEXT("TEXT"), TEXT("Toolbar Message"), MB_OK ) ;
break ;
}
return SUCCESS ;
}
L_INT TBSetCallbackExample( HWND hWnd , pTOOLBARHANDLE * ppLeadToolbar )
{
L_INT nRet;
static HWND hwndToolbarOwner ;
/* Save the owner window handle */
hwndToolbarOwner = hWnd ;
/* Set the toolbar callback with the owner window as the user defined data */
nRet = L_TBSetCallback ( *ppLeadToolbar, (pTOOLBARCALLBACK) LeadToolbarProc, ( L_VOID * ) &hwndToolbarOwner ) ;
if(nRet != SUCCESS)
return nRet;
return SUCCESS ;
}