Using the Container Callback

When an object is drawn in a container a series of states occur during the process of drawing that object. The state may be the beginning of the drawing process, a continuation of the drawing process, the ending of the drawing process, or the aborting of the drawing process. The following are the states currently supported for processing:

CONTAINER_STATE_BEGIN

CONTAINER_STATE_PROCESS

CONTAINER_STATE_END

CONTAINER_STATE_ABORT

These states are sent to a user-defined callback function for further user-defined processing. When the callback function is notified of the state of an object, information concerning the object being processed is also sent to the callback function. The callback function must adhere to the function prototype described in CONTAINERCALLBACK. The form of this callback function can also be seen below:

L_INT EXT_CALLBACK YourFunction( 
   pCONTAINERHANDLE pContainer, 
   CONTAINEREVENTTYPE nEventType, 
   L_VOID *pEventData, 
   L_VOID *pUserData); 

The callback function receives the following information:

The handle of the container that called the callback function.

The state of the object.

Extra information about the state of the object and the object itself.

Any user-defined information the user wishes to pass for processing.

Before a callback function can be used, it must be set for the container using the L_ContainerSetCallback function. To determine the callback function that is currently set for a container, call L_ContainerGetCallback.

The following example shows how to process the states of a line object:

L_INT EXT_CALLBACK LeadContainerProc( 
pCONTAINERHANDLE pContainer, 
CONTAINEREVENTTYPE nEventType, 
L_VOID *pEventData, 
L_VOID *pUserData) 
{ 
   pCONTAINEROBJECTDATA pObjectData = (pCONTAINEROBJECTDATA)pEventData; 
   switch (nEventType) 
   { 
      case CONTAINER_EVENT_TYPE_DRAW: 
      { 
         switch (pObjectData->nObjectType) 
         { 
            /* Process the line object events */ 
            case CONTAINER_OBJECT_TYPE_LINE: 
            { 
               switch (pObjectData->fState) 
               { 
                  case CONTAINER_STATE_BEGIN: 
                  /* do something */ 
                  break; 
                  case CONTAINER_STATE_PROCESS: 
                  /* do something */ 
                  break; 
                  case CONTAINER_STATE_END: 
                  /* do something */ 
                  break; 
                  case CONTAINER_STATE_ABORT: 
                  /* do something */ 
                  break; 
               } 
            } 
            break; 
         } 
      } 
      break; 
   } 
   return SUCCESS; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Container and Automation C API Help