AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Event Handler in Delphi

Ein Thema von FaNIX · begonnen am 30. Okt 2007 · letzter Beitrag vom 30. Okt 2007
Antwort Antwort
FaNIX

Registriert seit: 8. Okt 2007
36 Beiträge
 
#1

Event Handler in Delphi

  Alt 30. Okt 2007, 09:14
How do i set the event for a specific class event?

This is how it looks in VB.NET
Delphi-Quellcode:
        AddHandler FtpClient.MessageReceive, AddressOf FtpClient_MessageReceive
        AddHandler FtpClient.MessageSend, AddressOf FtpClient_MessageSend
Below is the hand coded event i want to assign to the class:
procedure FtpClient_Feedback(Sender : TObject; E : TKFP.Net.MessageArgs); Here is the declaration of the class event:


http://img136.imageshack.us/img136/3082/29591014oc2.jpg

The following doesnt work:

 Fo_FtpClient.MessageReceive := FtpClient_Feedback; I get the following errors:
[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]
  Mit Zitat antworten Zitat
30. Okt 2007, 09:31
Dieses Thema wurde von "Phoenix" von "Programmieren allgemein" nach "Object-Pascal / Delphi-Language" verschoben.
Delphi-Question -> Delphi board
Benutzerbild von sirius
sirius

Registriert seit: 3. Jan 2007
Ort: Dresden
3.443 Beiträge
 
Delphi 7 Enterprise
 
#3

Re: Event Handler in Delphi

  Alt 30. Okt 2007, 09:48
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)
Dieser Beitrag ist für Jugendliche unter 18 Jahren nicht geeignet.
  Mit Zitat antworten Zitat
Benutzerbild von Phoenix
Phoenix
(Moderator)

Registriert seit: 25. Jun 2002
Ort: Hausach
7.609 Beiträge
 
#4

Re: Event Handler in Delphi

  Alt 30. Okt 2007, 09:55
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 Include(Event, Eventhandler); or Exclude(Event, Eventhandler); instead of Event := handler; .
If you can understand a bit of german, then have a look at this excellent article from Sakura: http://www.delphipraxis.net/internal...=248261#248261
Sebastian Gingter
Phoenix - 不死鳥, Microsoft MVP, Rettungshundeführer
Über mich: Sebastian Gingter @ Thinktecture Mein Blog: https://gingter.org
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:09 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz