Autor Beitrag
huhn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 272
Erhaltene Danke: 1

WIN XP
D7Pers
BeitragVerfasst: So 24.10.10 14:24 
Hi Forum,
ich erstelle gerade eine eigene Klasse bei der ich ein event integrieren will mit Wertübergabe. Nur irgendwie steh ich auf dem Schlauch wie ich das am dümmsten machen soll und mit der Suche bin ich auch nicht richtig glücklich geworden.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Type blubb = class
  ...
  published
    property Event2:xxxx read yyyy;
  end;

//später im programm
procedure TForm1.OnEvent2(Sender:Tobject; msg:string);
begin
.
.
.
end;

so hatt ich mir das vorgestellt, wie man das mit normalen Events macht, also TNotifyevent ist mir klar nur das zu erweitern klappt irgendwie net so. Ich hoffe ihr könnt mir helfen.

mfg huhn

_________________
Quod Erat Demonstrandum-Was zu beweisen war! *THX to Chrissivo!*
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 24.10.10 14:32 
Definiere dir einen neuen Typ

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
Type
  TMeinTollesNeuesEvent = procedure(Sender: TObject, Dingens: Integer; Kirchens: Stringof Object;

// ...
// im Haupt-Typ

private
  fNeuesEvent : TMeinTollesNeuesEvent;

Public
  NeuesEvent: TMeinTollesNeuesEvent read fNeuesEvent write fNeuesEvent;

_________________
We are, we were and will not be.
Xion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
EE-Maler
Beiträge: 1952
Erhaltene Danke: 128

Windows XP
Delphi (2005, SmartInspect), SQL, Lua, Java (Eclipse), C++ (Visual Studio 2010, Qt Creator), Python (Blender), Prolog (SWIProlog), Haskell (ghci)
BeitragVerfasst: So 24.10.10 15:40 
Beim Aufrufen in der Klasse nicht vergessen, zu überprüfen, ob das Event auch "aboniert" wurde:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TBlubb.SchmeissEvent;
begin
  if Assigned(fNeuesEvent) then
     fNeuesEvent(Self, 42'42');
end;

_________________
a broken heart is like a broken window - it'll never heal
In einem gut regierten Land ist Armut eine Schande, in einem schlecht regierten Reichtum. (Konfuzius)
huhn Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 272
Erhaltene Danke: 1

WIN XP
D7Pers
BeitragVerfasst: So 24.10.10 23:28 
Danke euch ;)

_________________
Quod Erat Demonstrandum-Was zu beweisen war! *THX to Chrissivo!*