Solved

How do I deal with events containing parameters?

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

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 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