Posting an Event

If an event function is attached to a keycode, such as the F10 key (KEY_F10) or the Tab key (KEY_TAB), Vermont Views can process that event automatically. All keystrokes pressed by the user are automatically placed in the keyboard buffer, where Vermont Views can retrieve them. However, you are not limited to using keycodes to trigger your event functions. You can attach your event function to any type of event, including event codes you create in your application as discussed above. If you create your own event codes, they will not automatically be posted to the event queue. For Vermont Views to process them, you must post them to the event queue yourself.

To post an event from one of your functions, call the event post function, evnt_post():

int evnt_post(eventcode, wmsg, lmsg)
 
USHORT eventcode;
/* Type of event to post
*/
USHORT wmsg;    
/* Specifies additional message information 
*/
ULONG lmsg;
/* Specifies additional message information 
*/
   
*/
   
*/
   
*/
   
*/

For eventcode, specify the event code used in the call to et_rplevnt(). For wmsg and lmsg, you may specify any additional information that your event function needs. These parameters are copied into the event structure that is passed to your event function. The event structure looks like this:

struct event_struct

{
 
    ULONG lmsg;
/* Long message 
*/
    ULONG when;
/* Timestamp (in ticks)
*/
    USHORT type;
/* Event type
*/
    short x, y;
/* Mouse pos., or -1 if mouse not enabled
*/
    USHORT wmsg;
/* Word message
*/
} EVENT, *EVENTPTR;
 
*/

The values that you specify for lmsg and wmsg in your call to evnt_post() are placed in the lmsg and wmsg members in the event structure. The eventcode that you specify in your call to evnt_post() is placed in the type member of the event structure that is passed to your event function.

evnt_post() returns a 1 if the event was successfully posted, and a 0 if there was no room in the event queue to post the event. For more information on changing the size of the event queue, see Chapter 37, "How Event Processing Works."

You should be aware that events posted by your functions may not be processed immediately. Vermont Views posts many events to the event queue. Events are processed in the order in which they are placed in the queue. If there are already events in the event queue, these events will be processed first. If you code depends on the event function being called promptly, you should call the event function directly instead of posting an event.

More:

Values for wmsg and lmsg

Posting a Vermont Views Event

Code Example: Posting an Event to Suspend the Current Form


Home Contents Previous Next