![]() |
Event Handler in Delphi
How do i set the event for a specific class event?
This is how it looks in VB.NET
Delphi-Quellcode:
Below is the hand coded event i want to assign to the class:
AddHandler FtpClient.MessageReceive, AddressOf FtpClient_MessageReceive
AddHandler FtpClient.MessageSend, AddressOf FtpClient_MessageSend
Delphi-Quellcode:
Here is the declaration of the class event:
procedure FtpClient_Feedback(Sender : TObject; E : TKFP.Net.MessageArgs);
![]() The following doesnt work:
Delphi-Quellcode:
I get the following errors:
Fo_FtpClient.MessageReceive := FtpClient_Feedback;
[Pascal Error] u_fdn_FTP_Dot_Net.pas(93): E2298 read/write not allowed for CLR events. Use Include/Exclude procedure [Pascal Error] u_fdn_FTP_Dot_Net.pas(93): E2035 Not enough actual parameters [edit=Phoenix]Marked as a .NET topic. Mfg, Phoenix[/edit] |
DP-Maintenance
Dieses Thema wurde von "Phoenix" von "Programmieren allgemein" nach "Object-Pascal / Delphi-Language" verschoben.
Delphi-Question -> Delphi board |
Re: Event Handler in Delphi
One problem could be that your Ftp_client_feedback is a simple procedure and the property Messagerecieve waits for a "procedure of object" (a method within a class)
|
Re: Event Handler in Delphi
Nope. As the compiler says: In Delphi.NET you must use the Include/Exclude functions to add/delete Eventhandler. That's because in CLR you always have multicast delegates (you can add more than one handler to a single event at a given time), and Delphi does not know the += / -= syntax to add / remove a single handler from an event. So you have to use
Delphi-Quellcode:
or
Include(Event, Eventhandler);
Delphi-Quellcode:
instead of
Exclude(Event, Eventhandler);
Delphi-Quellcode:
.
Event := handler;
If you can understand a bit of german, then have a look at this excellent article from Sakura: ![]() |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:27 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz