Solved

Using COM events

Posted on 1998-10-20
3
139 Views
Last Modified: 2010-04-06
I am using a third party COM component.  It has two interfaces declared.  The first allows control of the component, which is working, and the second has three event methods.

The question is, how do you attach a procedure in the Delphi object to the COM event method?
0
Comment
Question by:bcrotaz
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 200 total points
Comment Utility
When you import the type library Delphi should create methods that correspond to these events. You then put the code to handle the events in those methods.

Cheers,

Raymond.
0
 
LVL 1

Author Comment

by:bcrotaz
Comment Utility
If I do this, and at some point in the future I re-import the type library, won't I lose the code in these methods?
0
 
LVL 12

Expert Comment

by:rwilson032697
Comment Utility
You might do. But then thats what copy and paste was invented for! :-)

If the events are declared the same way as events in VCL control eg Property OnClick: TNotifyEvent...  you should be able to just assign an appropriate method from one of your own classes to that event

eg: below is an excerpt from a class created when I imported a type library...

    function Get_EventHandler: IExchangeEvents; safecall;
    procedure Set_EventHandler(const Value: IExchangeEvents); safecall;
    property EventHandler: IExchangeEvents read Get_EventHandler write Set_EventHandler;

  You should be able to assign a method to EventHandler...

Cheers,

Raymond.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now