#include "LtCon.h"
L_LTCON_API L_INT L_ContainerSetCallback(pContainer, pCallback, pUserData)
pCONTAINERHANDLE pContainer; |
pointer to a container handle |
const pCONTAINERCALLBACK pCallback; |
optional callback function |
L_VOID * pUserData; |
pointer to more parameters for the callback |
Specifies a callback function for handling container events.
Parameter |
Description |
pContainer |
Pointer to a container 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 CONTAINERCALLBACK 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. |
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Required DLLs and Libraries
LTCON For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application |
Functions: |
|
Topics: |
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;}