2
votes

A common occurrence with the VCL is building a component and then filling in its event handlers with code that resides in the host Frame or Form (if the component has Events). The Delphi 6 IDE is capable of cutting and pasting a component from its host Frame or Form into a new Frame or Form quite handily. But the code residing in the event handlers on the source Frame or Form is not copied along with it.

Has anybody seen a utility or perhaps an IDE expert for Delphi 6 that can also copy the event handler code too while duplicating the Event declarations in the destination PAS file and updating the destination DFM file properly too?

1
This is a great question. I've often thought of writing one as I've never found one that can handle my real applications.Warren P

1 Answers

1
votes

I don't know of any expert that would grab the EventHandlers code and duplicate it in another host context.
Keep in mind that a simple copy and paste of the code might not work as it would be in a different scope where the available properties and routines are not necessarily the same.
If you need to share handlers between hosts, I'd suggest you put the code in a common unit and call it from the hosts.
Or you can have a base Form or Frame and inherit from it...