Solved

How do I deal with events containing parameters?

Posted on 2015-01-28
4
129 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

911 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

21 Experts available now in Live!

Get 1:1 Help Now