    |

|
White Papers -
Articles
|
|
"Creating
Synergistic Components with Delphi"
|
|
James Callan
- KOG Webzine (Page 8)
|
Overriding Events
Referring back to the listing in Figure 1, recall that to define an event handler for
a custom component you provided a default event handler as well as a method pointer
to save the user's event handler. Our macro recorder will do exactly the same thing,
but it will do it at run-time rather than at design time. Additionally, the macro
recorder will need to provide a method pointer for each prospective client instead
of a single pointer for the user. Since it is unknown just how many clients will
exist until run-time, a dynamic linked list of method pointers will be used. Moreover,
the macro recorder will need to override the form's OnCreate to create the linked
list just prior to calling the form's original OnCreate handler.
The difference between defining events in custom components and dynamically overriding
events lies in when things occur. Defining events for custom components is a component
design activity; whereas, dynamically overriding event handlers is a run-time activity.
For this reason, the RTTI operatives "is" and "as" are common
in components that feature dynamic event overriding. |
 
|