L_TBSetCallback
#include "LtTLB.h"
L_INT EXT_FUNCTION L_TBSetCallback(pToolbar, pCallback, *pUserData )
pTOOLBARHANDLE pToolbar; |
/* pointer to a toolbar handle */ |
const pTOOLBARCALLBACK pCallback; |
/* optional callback function */ |
/* 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 L_FAR *. 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 L_FAR *pUserData
)
{
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 ;
}
/* Global toolbar handle */
pTOOLBARHANDLE g_pLeadToolbar ;
L_INT ToolbarTest ( HWND hWnd )
{
static HWND hwndToolbarOwner ;
/* Save the owner window handle */
hwndToolbarOwner = hWnd ;
/* Initiate the toolbar handle */
L_TBInit ( &g_pLeadToolbar ) ;
if (SUCCESS == L_TBIsValid ( g_pLeadToolbar ) ) /* check the validity of the toolbar handle */
{
/* Create the toolbar */
L_TBCreate ( g_pLeadToolbar, hWnd, TEXT("Tools Window"), TOOLBAR_PAINT ) ;
/* Show the toolbar */
L_TBSetVisible ( g_pLeadToolbar, TRUE ) ;
/* Set the toolbar callback with the owner window as the user defined data */
L_TBSetCallback ( g_pLeadToolbar, LeadToolbarProc, ( L_VOID L_FAR * ) &hwndToolbarOwner ) ;
}
return SUCCESS ;
}