Solved

How do I deal with events containing parameters?

Posted on 2015-01-28
4
132 Views
Last Modified: 2015-05-17
I have a .tlb that originated from a C# .net dll that gives me the following

// *********************************************************************//
// OLE Server Proxy class declaration
// Server Object    : TDesktopClient
// Help String      :
// Default Interface: _DesktopClient
// Def. Intf. DISP? : No
// Event   Interface: IClientEvents
// TypeFlags        : (2) CanCreate
// *********************************************************************//
  TDesktopClient = class(TOleServer)
.... and so on

where OnContactData is defined in the .tlb as
property OnContactData: TDesktopClientContactData read FOnContactData write FOnContactData;

and TDesktopClientContactData is defined in the .tlb as
TDesktopClientContactData = procedure(ASender: TObject; const data: _ContactData) of object

and FOnContactData in the .tlb as
FOnContactData: TDesktopClientContactData;

So as far as my understanding goes I will need to add the following to my own form,

TDeskTop:= TDesktopClient.Create(self);
TDeskTop.OnContactData:=Call;

The question is really, how do I deal with the OnContactData in a way that I can access the _ContactData parameter?

(My guess is that I need to create something similar to .OnContactData but I am not sure exactly how I would do this to access the _ContactData object.)
0
Comment
Question by:Tim Bowers
  • 2
4 Comments
 
LVL 24

Accepted Solution

by:
jimyX earned 500 total points
ID: 40575009
The question is really, how do I deal with the OnContactData in a way that I can access the _ContactData parameter?
You are going to access it when you are going to instantiate something from the class. Same happens to when trying to access Sender of OnChange event of the simple TEdit.

{At its basic level, this is hidden structure which is similar to "TDesktopClient = class(TOleServer)" structure, which you can't use until you instantiate the class.}
TNotifyEvent = procedure(Sender: TObject) of object;
...
FOnChange: TNotifyEvent;
...
property OnChange: TNotifyEvent read FOnChange write FOnChange;

Open in new window


When you say:
TDeskTop.OnContactData:= Call;

Open in new window


It means you have somewhere the following procedure:
procedure TForm1.Call(ASender: TObject; const data: _ContactData);
begin
  {And here you can make use of data (the _ContactData object)}
end;

Open in new window

0
 
LVL 24

Assisted Solution

by:jimyX
jimyX earned 500 total points
ID: 40575030
JIC: Make sure to declare "Call" to match "procedure(ASender: TObject; const data: _ContactData) of object".

i.e. somewhere in you TForm's class:
type
  TForm1 = class(TForm)
    ...
    private
      procedure Call(ASender: TObject; const data: _ContactData);
  end;

Open in new window

0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 40781532
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

679 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