OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Adding Your Own View Events

You can use the VN_DEFINE and NOTIFY_SIG macros to post your own custom view events and to define corresponding response table macros and event-handling functions.

This section describes how to define an event and set up the event-handling function and response table macro for that event.

First you must define the name of the event you want to handle. By convention, this name should begin with the letters vn followed by the event name. A custom view event should be defined as a const int greater than the value vnCustomBase. You can define your event values as being vnCustomBase plus some offset value.

For example, suppose you are defining an event called vnPenChange. The code would look something like this:

const int vnPenChange = vnCustomBase + 1;

Next use the NOTIFY_SIG macro to specify the signature of the event-handling function. The NOTIFY_SIG macro takes two parameters: the event name and the exact parameter type to be passed to the function. The size of this parameter can be no larger than type long; if the object being passed is larger than a long, you must pass it by pointer. For example, suppose for the vnPenChange event, you want to pass a TPen object to the event-handling function. Because a TPen object is quite a bit larger than a long, you must pass the object by pointer. The macro would look something like this:

Now you need to define the response table macro for your event. By convention, the macro name uses the event name, in all uppercase letters, preceded by EV_VN_. Use the #define macro to define the macro name. Use the VN_DEFINE macro to define the macro itself. This macro takes three parameters:

  • Event name
  • Event-handling function name (by convention, the same as the event name preceded by Vn instead of the vn used for the event name)
  • Size of the parameter for the event-handling function; this can have four different values:
    • void
    • int (size of an int parameter depends on the platform)
    • long (32-bit integer or far pointer)
    • pointer (size of a pointer parameter depends on the memory model)

Specify the value that most closely corresponds to the event-handling function's parameter type.

The definition of the response table macro for the vnPenChange event would look something like this:

#define EV_VN_PENCHANGE \
VN_DEFINE(vnPenChange, VnPenChange, pointer)
Note
The third parameter of the VN_DEFINE macro in this case is pointer. It indicates the size of the value passed to the event-handling function.

See Also