Solved

How do I deal with events containing parameters?

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

786 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