L_TBSetCallback

Summary

Specifies the callback function that will be used to notify the user about the toolbar events.

Syntax

#include "LtTLB.h"

L_LTTLB_API L_INT L_TBSetCallback(pToolbar, pCallback, pUserData)

Parameters

pTOOLBARHANDLE pToolbar

Pointer to a toolbar handle.

const pTOOLBARCALLBACK 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 the TOOLBARCALLBACK function.

L_VOID * 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 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.

Returns

Value Meaning
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

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 ; 
 
   /* 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 ; 
} 

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Toolbar C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.