Solved

How do I deal with events containing parameters?

Posted on 2015-01-28
4
128 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
Comment Utility
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
Comment Utility
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 36

Expert Comment

by:Geert Gruwez
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

6 Experts available now in Live!

Get 1:1 Help Now