LVectorBase::VectorEventProcCallBack

#include "ltwrappr.h"

virtual L_INT LVectorBase::VectorEventProcCallBack(pVector, uLevel, pEvent, pUserData)

pVECTORHANDLE pVector;

pointer to a vector handle

L_UINT uLevel;

event level

pVECTOREVENT pEvent;

pointer to a vector event

L_VOID * pUserData;

pointer to additional parameters

Processes each event that occurs inside the vector handle.

Parameter

Description

pVector

Pointer to the vector handle in which the event occurred.

uLevel

Level of the event that occurred. For a top-level event, this value is 0. For a second level event this value is 1, etc. For an example, refer to the Comments section below.

pEvent

Pointer to a VECTOREVENT structure that describes the event that occurred in the vector handle.

pUserData

A void pointer that you can use to access a variable or structure containing data that your callback function needs. This gives you a way to receive data indirectly from the function that uses this callback function.

 

Keep in mind that this is a void pointer, which must be cast to the appropriate data type within your callback function.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

To use this function you must derive a class from LVectorBase and override the VectorEventProcCallBack function.

To understand event levels, consider this example:

Assume the clipboard contains a vector handle with 1 layer and 2 objects inside this layer.

Now you execute LVectorBase::CopyFromClipboard, the toolkit may fire these events in the following sequence:

pEvent->uType

pEvent->Status

uLevel

Comment

VECTOR_EVENT_COPYFROMCLIPBOARD

VECTOR_EVENT_BEFORE

0

LVectorBase::CopyFromClipboard is about to execute.

VECTOR_EVENT_ADDLAYER

VECTOR_EVENT_BEFORE

1

LVectorBase::AddLayer is about to execute.

VECTOR_EVENT_ADDOBJECT

VECTOR_EVENT_BEFORE

2

LVectorBase::AddObject for first object is about to execute.

VECTOR_EVENT_ADDOBJECT

VECTOR_EVENT_AFTER

2

LVectorBase::AddObject for first object has been completed.

VECTOR_EVENT_ADDOBJECT

VECTOR_EVENT_BEFORE

2

LVectorBase::AddObject for second object is about to execute.

VECTOR_EVENT_ADDOBJECT

VECTOR_EVENT_AFTER

2

LVectorBase::AddObject for second object has been completed.

VECTOR_EVENT_ADDLAYER

VECTOR_EVENT_AFTER

1

LVectorBase::AddLayer has been completed.

VECTOR_EVENT_COPYFROMCLIPBOARD

VECTOR_EVENT_AFTER

0

LVectorBase::CopyFromClipboard has been completed.

Your callback can monitor all these operations and cancels whatever operation you want.

See Also

Functions:

LVectorBase::Event

Topics:

Vector Handle Events

Example

This example defines a new event consisting of a rotate, translate and a scale. A message is displayed in the Event callback before the event and after the event. LVectorBase::Event() VectorEventProcCallBack

#define MY_CUSTOM_EVENT (VECTOR_EVENT_USER+1) 
class LMyVector2: public LVectorBase 
{ 
protected: 
   L_INT  LMyVector2::VectorEventProcCallBack( 
   pVECTORHANDLE pVector, 
   L_UINT uLevel, 
   pVECTOREVENT pEvent, 
   L_VOID *pUserData 
   ); 
}; 
L_INT  LMyVector2::VectorEventProcCallBack( 
pVECTORHANDLE pVector, 
L_UINT uLevel, 
pVECTOREVENT pEvent, 
L_VOID *pUserData 
) 
{ 
   L_TCHAR *pszMsg= TEXT(""); 
   if (pEvent->uType == MY_CUSTOM_EVENT) 
   { 
      switch (pEvent->Status) 
      { 
         case VECTOR_EVENT_STATUS_BEFORE: 
         pszMsg = TEXT("Before MY_CUSTOM_EVENT"); 
         break; 
         case VECTOR_EVENT_STATUS_AFTER: 
         pszMsg = TEXT("After MY_CUSTOM_EVENT"); 
         break; 
      } 
      MessageBox(NULL, pszMsg, TEXT(""), MB_OK); 
   } 
   return LVectorBase::VectorEventProcCallBack(pVector, uLevel, pEvent, pUserData); 
} 
L_INT LVectorBase__VectorEventProcCallBackExample( LVectorBase *pVector) 
{ 
   L_INT       nRet = SUCCESS; 
   VECTOREVENT Event; 
   VECTORPOINT Point; 
   // Fire our new event, giving all event callbacks in the vector handle a chance to cancel our operation 
   memset( &Event, 0, sizeof( Event ) ); 
   Event.nSize = sizeof( Event ); 
   Event.uType = MY_CUSTOM_EVENT; 
   Event.Status = VECTOR_EVENT_STATUS_BEFORE; 
   nRet = pVector->Event(&Event); 
   if( nRet != SUCCESS ) 
   { 
      //a callback has returned something other than success, we should cancel 
      return nRet; 
   } 
   // do the operation, for example, rotate, translate and scale 
   Point.x = 10.0; Point.y = 20.0; Point.z = 30.0; 
   nRet = pVector->SetRotation( &Point); 
   if(nRet != SUCCESS) 
      return nRet; 
   Point.x = 4.0; Point.y = 4.0; Point.z = 4.0; 
   nRet = pVector->SetTranslation(&Point ); 
   if(nRet != SUCCESS) 
      return nRet; 
   Point.x = 0.5; Point.y = 0.5; Point.z = 0.5; 
   nRet = pVector->SetScale(&Point ); 
   if(nRet != SUCCESS) 
      return nRet; 
   // notify the vector handle that the operation is done 
   Event.Status = VECTOR_EVENT_STATUS_AFTER; 
   nRet = pVector->Event(&Event ); 
   if(nRet != SUCCESS) 
      return nRet; 
   return SUCCESS; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Vector C++ Class Library Help