L_VecSetEventCallback

#include "lvkrn.h"

L_INT EXT_FUNCTION L_VecSetEventCallback(pVector, pProc, pUserData, pOldProc, pOldUserData)

pVECTORHANDLE pVector;

/* pointer to a vector handle */

pVECTOREVENTPROC pProc;

/* pointer to your callback function */

L_VOID L_FAR * pUserData;

/* pointer to more parameters for the callback */

ppVECTOREVENTPROC pOldProc;

/* pointer to a pointer */

L_VOID L_FAR **pOldUserData;

/* pointer to more parameters for the old callback function */

Sets a new vector event callback.

Parameter

Description

pVector

Pointer to a vector handle.

pProc

Your callback function that supplies the information that LEADTOOLS needs when handling events. The callback function must adhere to the syntax specified in VECTOREVENTPROC.

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.

pOldProc

Pointer to a pointer to a VECTOREVENTPROC that will be updated with the old callback function.

pOldUserData

Pointer to the additional data used by the old callback function.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

For information about the types of events the vector handle can generate, refer to the VECTOREVENT structure.

Required DLLs and Libraries

LVKRN

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:

L_VecEvent, VECTOREVENTPROC

Topics:

Vector Handle Events

Example

/* This example will disable L_VecSetRotation */

#define VECTOR_ERROR_USERNOROTATION    -20000

typedef struct tagDATA
{
   pVECTOREVENTPROC pOldProc;
   L_VOID *pOldUserData;
}
DATA, *LPDATA;

L_INT EXT_CALLBACK VectorEventProc( pVECTORHANDLE pVector, L_UINT uLevel, pVECTOREVENT pEvent, L_VOID L_FAR *pUserData )
{
   L_INT nRet;
   LPDATA pData;

   pData = (LPDATA) pUserData;

   /* call the old event handler */
   nRet = pData->pOldProc( pVector, uLevel, pEvent, pData->pOldUserData );
   if( nRet != SUCCESS )
      return nRet;

   /* disable rotation */
   if( uLevel == 0 && /* top level event */
       pEvent->uType == VECTOR_EVENT_ROTATION && /* from a L_VecSelectObject call */
       pEvent->Status == VECTOR_EVENT_STATUS_BEFORE ) /* before any action is taken */
      return VECTOR_ERROR_USERNOROTATION;

   return SUCCESS;
}

void DisableRotation( pVECTORHANDLE pVector )
{
   LPDATA pData;

   /* set a new vector event callback */
   pData = (LPDATA) GlobalAllocPtr( GHND, sizeof( LPDATA ) );
   L_VecSetEventCallback( pVector, VectorEventProc, pData, &pData->pOldProc, &pData->pOldUserData );
}

void TestFunction( pVECTORHANDLE pVector )
{
   L_INT nRet;
   VECTORPOINT Point;

   /* try to call L_VecSetRotation */
   Point.x = 10.0;
   Point.y = 20.0;
   Point.z = 30.0;
   nRet = L_VecSetRotation( pVector, &Point, NULL, NULL, 0L );

   /* nRet should be VECTOR_ERROR_USERNOROTATION, the value returned from VectorEventProc */
}