L_ContainerSetCallback

Summary

Specifies a callback function for handling container events.

Syntax

#include "LtCon.h"

L_LTCON_API L_INT L_ContainerSetCallback(pContainer, pCallback, pUserData)

Parameters

pCONTAINERHANDLE pContainer

Pointer to a container handle.

const pCONTAINERCALLBACK 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 CONTAINERCALLBACK 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 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

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Required DLLs and Libraries

See Also

Functions

Topics

Example

 L_INT EXT_CALLBACK LeadContainerProc(pCONTAINERHANDLE    pContainer, 
                                     CONTAINEREVENTTYPE  nEventType, 
                                     L_VOID*             pEventData, 
                                     L_VOID*             pUserData) 
{ 
   UNREFERENCED_PARAMETER(pContainer); 
   UNREFERENCED_PARAMETER(pEventData); 
   UNREFERENCED_PARAMETER(pUserData); 
   pCONTAINEROBJECTDATA pObjectData = ( pCONTAINEROBJECTDATA ) pEventData ; 
 
   switch ( nEventType ) 
   { 
   case CONTAINER_EVENT_TYPE_DRAW: 
      { 
         switch ( pObjectData->nObjectType ) 
         { 
            /* Process the point object events */ 
         case CONTAINER_OBJECT_TYPE_POINT: 
            { 
               switch ( pObjectData->fState ) 
               { 
               case CONTAINER_STATE_BEGIN: 
                  break ; 
 
               case CONTAINER_STATE_PROCESS: 
                  break ; 
 
               case CONTAINER_STATE_END: 
                  break ; 
 
               case CONTAINER_STATE_ABORT: 
                  break ; 
               } 
            } 
 
            break ; 
 
            /* Process the line object events */ 
         case CONTAINER_OBJECT_TYPE_LINE: 
            { 
               switch ( pObjectData->fState ) 
               { 
               case CONTAINER_STATE_BEGIN: 
                  break ; 
 
               case CONTAINER_STATE_PROCESS: 
                  break ; 
 
               case CONTAINER_STATE_END: 
                  break ; 
 
               case CONTAINER_STATE_ABORT: 
                  break ; 
               } 
            } 
            break ; 
 
            /* Process the square object events */ 
         case CONTAINER_OBJECT_TYPE_SQUARE: 
            { 
               switch ( pObjectData->fState ) 
               { 
               case CONTAINER_STATE_BEGIN: 
                  break ; 
 
               case CONTAINER_STATE_PROCESS: 
                  break ; 
 
               case CONTAINER_STATE_END: 
                  break ; 
 
               case CONTAINER_STATE_ABORT: 
                  break ; 
               } 
            }  
            break ; 
 
            /* Process the rectangle object events */ 
         case CONTAINER_OBJECT_TYPE_RECT: 
            { 
               switch ( pObjectData->fState ) 
               { 
               case CONTAINER_STATE_BEGIN: 
                  break ; 
 
               case CONTAINER_STATE_PROCESS: 
                  break ; 
 
               case CONTAINER_STATE_END: 
                  break ; 
 
               case CONTAINER_STATE_ABORT: 
                  break ; 
               } 
            } 
            break ; 
 
            /* Process the circle object events */ 
         case CONTAINER_OBJECT_TYPE_CIRCLE: 
            {   
               switch ( pObjectData->fState ) 
               { 
               case CONTAINER_STATE_BEGIN: 
                  break ; 
 
               case CONTAINER_STATE_PROCESS: 
                  break ; 
 
               case CONTAINER_STATE_END: 
                  break ; 
 
               case CONTAINER_STATE_ABORT: 
                  break ; 
               } 
            } 
            break ; 
 
            /* Process the ellipse object events */ 
         case CONTAINER_OBJECT_TYPE_ELLIPSE: 
            { 
               switch ( pObjectData->fState ) 
               { 
               case CONTAINER_STATE_BEGIN: 
                  break ; 
 
               case CONTAINER_STATE_PROCESS: 
                  break ; 
 
               case CONTAINER_STATE_END: 
                  break ; 
 
               case CONTAINER_STATE_ABORT: 
                  break ; 
               } 
            } 
            break ; 
 
            /* Process the polyline object events */ 
         case CONTAINER_OBJECT_TYPE_POLYLINE: 
            { 
               switch ( pObjectData->fState ) 
               { 
               case CONTAINER_STATE_BEGIN: 
                  break ; 
 
               case CONTAINER_STATE_PROCESS: 
                  break ; 
 
               case CONTAINER_STATE_END: 
                  break ; 
 
               case CONTAINER_STATE_ABORT: 
                  break ; 
               } 
            } 
            break ; 
 
            /* Process the bezier object events */ 
         case CONTAINER_OBJECT_TYPE_BEZIER: 
            { 
               switch ( pObjectData->fState ) 
               { 
               case CONTAINER_STATE_BEGIN: 
                  break ; 
 
               case CONTAINER_STATE_PROCESS: 
                  break ; 
 
               case CONTAINER_STATE_END: 
                  break ; 
 
               case CONTAINER_STATE_ABORT:  
                  break ; 
               } 
            } 
            break ; 
               } 
         } 
         break ; 
   } 
   return SUCCESS ; 
} 
 
L_INT ContainerSetCallbackExample(HWND hWnd, pCONTAINERHANDLE * ppContainer) 
{ 
   L_INT nRet; 
   CONTAINERMETRICS Metrics ; 
 
   /* If the contianer doesn't exist, create the container and attach it to its owner window */ 
   if(ppContainer != NULL) 
   { 
      /* check the validity of the container handle */ 
      nRet = L_ContainerIsValid ( *ppContainer ); 
      if(nRet != SUCCESS) 
         *ppContainer = NULL; 
   } 
 
   if(*ppContainer == NULL) 
   { 
      /* Initiate the container handle */ 
      nRet = L_ContainerInit ( ppContainer ) ; 
      if(nRet != SUCCESS) 
         return nRet; 
      nRet = L_ContainerCreate ( *ppContainer, hWnd ) ; 
      if(nRet != SUCCESS) 
         return nRet; 
   } 
 
   /* check the validity of the container handle */ 
   nRet = L_ContainerIsValid ( *ppContainer ); 
   if (nRet == SUCCESS ) 
   { 
      /* Set the container object type to rectangle */ 
      nRet = L_ContainerSetObjectType ( *ppContainer, CONTAINER_OBJECT_TYPE_RECT ) ; 
      if(nRet != SUCCESS) 
         return nRet; 
 
      /* Initiate the container metrics */ 
      Metrics.nSize = sizeof ( CONTAINERMETRICS ) ; 
      Metrics.dwMask = CMF_LIMITS ; 
 
      /* Set the container limits to some value */ 
      SetRect ( &Metrics.rcLimits, 0, 0, 500, 500 ) ; 
 
      /* Set the container metrics */ 
      nRet = L_ContainerSetMetrics ( *ppContainer, &Metrics ) ; 
      if(nRet != SUCCESS) 
         return nRet; 
 
      nRet = L_ContainerSetCallback ( *ppContainer, LeadContainerProc, NULL ) ;  
   } 
   return nRet; 
} 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

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