Solved

Using COM events

Posted on 1998-10-20
3
143 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 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