Suppose I have a control on my form that I want to link a certain component
to that will intercept some of the messages to the control and make it
behave differently; eg. suppose I want to intercept the control's OnKeyPress
event and perform an action based on it. Assume that this control could
actually be any TWinControl descendant, not something I've specifically
created myself.
The only way I can think of to do this is either to reassign the control's
OnKeyPress event or its WindowProc to one controlled by the new component.
But this is a logistical nightmare either way! Take WindowProc for example:
If my component assigns the control's WindowProc to one of its own
procedures on creation and assigns it to the old value on destruction (eg. a
TDockTree does this), then that is fine as long as no other component has
done the same thing. But if I have two components (for example) and, in
order, create component one, create component two, free one, and free two,
the WindowProc for the control will end up pointing to that of component one
- which has already been free'd!!
I could implement a stack to hold WindowProc changes for the control, and
use methods on this stack to keep things in order. But everything will be
broken if any third party component does the same thing, eg. if the control
were a docksite, because TDockTree will reassign its WindowProc at the point
it is created.
Reassigning the OnKeyPress event would encounter similar problems. Is there
any way around this?
Cheers,
Carl
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz