Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
L_TBSetCallback
#include "LtTLB.h"
L_LTTLB_API L_INT L_TBSetCallback(pToolbar, pCallback, pUserData )
pTOOLBARHANDLE pToolbar; |
/* pointer to a toolbar handle */ |
const pTOOLBARCALLBACK pCallback; |
/* optional callback function */ |
L_VOID * pUserData; |
/* pointer to more parameters for the callback */ |
Specifies a callback function that will be used to notify the user about the toolbar events.
Parameter |
Description |
pToolbar |
Pointer to a toolbar handle. |
pCallback |
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 TOOLBARCALLBACK Function. |
pUserData |
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 you need. 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, you can pass NULL in this parameter. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes |
Comments
To determine the current callback function used to notify the user of toolbar events, call L_TBGetCallback.
Required DLLs and Libraries
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.
See Also
Functions: |
|
Topics: |
Example
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 ; /* Initiate the toolbar handle */ nRet = L_TBInit ( ppLeadToolbar ) ; if(nRet != SUCCESS) return nRet; nRet = L_TBIsValid ( *ppLeadToolbar ); if (SUCCESS == nRet) /* check the validity of the toolbar handle */ { /* Create the toolbar */ nRet = L_TBCreate ( *ppLeadToolbar, hWnd, TEXT("Tools Window"), TOOLBAR_PAINT ) ; if(nRet != SUCCESS) return nRet; /* Show the toolbar */ nRet = L_TBSetVisible ( *ppLeadToolbar, TRUE ) ; if(nRet != SUCCESS) return nRet; /* 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; } else return nRet; return SUCCESS ; }