?
Solved

Using COM events

Posted on 1998-10-20
3
Medium Priority
?
146 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 600 total points
ID: 1343536
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
ID: 1343537
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
ID: 1343538
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

762 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