views:

515

answers:

1

You know in Visual Studio you can use the "+=" syntax and a couple tabs to have it autogenerate the code for an event handler?

How do I accomplish the same thing in Delphi? I'm trying to create an event handler for an event in an invisible activex library that I've imported using the Import Component function.

I realize that with imported activex controls you can just click the object, browse the events tab for what the component provides and double click on the event to have it generate one for you.

These particular activex components are invisible so you can select them on the form. Can Delphi autogenerate the code? If not, can someone point me to some sample code?

+5  A: 

In Delphi, even non-visual components are represented on the form as small boxes with an icon. Just select that component and you can get to the events from the object inspector.

If you didn't install it on the component pallet, then there is no autogeneration of the code for the event handler. The easiest way would be to go into the generated tlb.pas file and find the signature of the event you want, copy it, and make a compatible method for it. Then just point the event property to that new method.

Jim McKeeth
Exactly right. Although an example (for the second part) might be in order.
Rob Kennedy
You're assuming that the OP has already imported the ActiveX and thus already generated the _TLB.pas file. I'm not sure that is the case.
Oliver Giesen