Purpose |
Attach or detach an event handler to/from an event source. |
Syntax |
EVENTS FROM ObjSource
CALL ObjEvent |
Remarks |
In the above source code sample, ObjEvent is an object variable which references an event handler object, and ObjSource is an object variable which references an event source object which generates events. The EVENTS FROM statement attaches event handler code to an event source object variable. The object variable ObjEvent must be declared as a supported event interface, while ObjSource specifies the event source interface. EVENTS END detaches the event handler from the event source. Generally speaking, a server object "sources" events, and a client object "handles" events by supplying a METHOD which is called by the server to perform a user-defined notification. This event handler is code in the client object, which is sometimes referred to as an "event sink" (analogous to the electrical engineering terms source/sink). One or more clients may choose to "subscribe" to events from a server object by executing the EVENTS FROM statement. The subscription is terminated by execution of the EVENTS END statement. When the server executes RAISEEVENT or OBJECT RAISEEVENT, all clients which have subscribed to these events are called. PowerBASIC servers support up to 32 concurrent client subscribers per server object. Event sources and event handlers may be used within a single module, or through COM services supplied by the Windows operating system. |
See also |
CLASS, INTERFACE (Direct), INTERFACE (IDBind), Just what is COM?, OBJECT RAISEEVENT, RAISEEVENT, What is an object, anyway?, What are Connection Points? |
Example |
#COMPILE EXE |