Autor Beitrag
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 09.02.07 21:29 
Habe mir einen eigenen Ereignistyp deklariert:
ausblenden Delphi-Quelltext
1:
2:
//happens if a class is changed
  TOnClassChangeEvent = procedure(Sender: TObject; ClassIndex: integer) of object;

Habe auch dementsprechend eine Prozedur deklariert:
ausblenden Delphi-Quelltext
1:
 procedure ClassChanged(Sender: TObject; ClassIndex: integer);					

Wenn ich diese Prozedur nun dem OnClassChange-Event eines Objektes zuweisen will, gibt es einen Fehler:
ausblenden Delphi-Quelltext
1:
cl.OnClassChange := ClassChanged(cl,cl.id);					

Delphi hat folgendes geschrieben:

[Fehler] ClassList.pas(119): Inkompatible Typen: 'TOnClassChangeEvent' und 'procedure, untyped pointer or untyped parameter'

Das kann ich mir nicht erklären.

Bei TNotifyEvent geht es doch genauso. :(

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 09.02.07 22:10 
Der Fehler ist, dass Du die Parameter schon bei der Zuweisung übergibst. Die Parameter sind ja bei jedem Auslösen des Ereignisses verschieden, es macht keinen Sinn, diese mit zu übergeben.

Einem Ereignis übergibst Du wirklich nur die Methode:
ausblenden Delphi-Quelltext
1:
cl.OnClassChange := ClassChanged;					

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 10.02.07 13:48 
Klappt! :zustimm:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot