Autor Beitrag
cuejo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP
Delphi 7 Personal und 2005 PE
BeitragVerfasst: Do 05.10.06 17:49 
Hi,
Für meine Komponente würde ich gerne ein OnCreate-Ereigniss schreiben. Ich habe schon verschidenste Ereignisse wie z.B. OnPaint eingefügt. Das war ja noch relativ einfach. Nun weiß ich aber nicht, wie man einOnCreate-Ereigniss programmiert, da man doch darauf warten muss, bis die Klasse erstellt wurde bzw. der Konstruktor seine Arbeit verrichtet hat. Kann mir da jemand eine Hilfestellung geben? :roll:

_________________
Computer sind dumm, aber fleißig. Deshalb arbeite ich so gerne damit.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.10.06 17:59 
Du brauchst ja nur dafür zu sorgen, das die mit der property verlinkte Methode im Konstruktor aufgerufen wird.

_________________
Markus Kinzler.
cuejo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP
Delphi 7 Personal und 2005 PE
BeitragVerfasst: Do 05.10.06 18:09 
user profile iconmkinzler hat folgendes geschrieben:
Du brauchst ja nur dafür zu sorgen, das die mit der property verlinkte Methode im Konstruktor aufgerufen wird.

Eben das geht ja irgentwie nicht. :gruebel:

_________________
Computer sind dumm, aber fleißig. Deshalb arbeite ich so gerne damit.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.10.06 18:14 
Was meinst du mit geht nicht?

_________________
Markus Kinzler.
cuejo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP
Delphi 7 Personal und 2005 PE
BeitragVerfasst: Do 05.10.06 18:19 
Wenn ich das so mache, dann passiert rein gar nichts, obwohl ich dem OnCreate eine Methode zuweise...

_________________
Computer sind dumm, aber fleißig. Deshalb arbeite ich so gerne damit.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.10.06 18:33 
Poste mal den Code.

_________________
Markus Kinzler.
cuejo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP
Delphi 7 Personal und 2005 PE
BeitragVerfasst: Do 05.10.06 18:47 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
...
type
  TBspKlasse = class(TGraphicControl)
  private
    FOnCreate: TNotifyEvent;
    ...
  protected
    procedure DoCreate;
    ...
  published
    property OnCreate: TNotifyEvent read FOnCreate write FOnCreate;
    ...
  end;

...

constructor TBspKlasse.Create(AOwner: TComponent);
begin
...
DoCreate; // Wenn ich dich richtig verstanden habe, dann kommt das hier rein.
end;

procedure TPattern.DoCreate;
begin
if Assigned(FOnCreate) then FOnCreate(Self);
end;
...

Und wenn ich später OnCreate eine Methode zuweise, dann wird diese nicht ausgeführt. Ich dachte also, dass das DoCreate; irgendwo anders hinkommt, an einer Stelle, an der Create bereits vollständig ausgeführt wurde. Nur wo? Oder habe ich dich falsch verstanden?

_________________
Computer sind dumm, aber fleißig. Deshalb arbeite ich so gerne damit.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.10.06 18:49 
Du kannst es auch mal in Loaded versuchen

_________________
Markus Kinzler.
cuejo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP
Delphi 7 Personal und 2005 PE
BeitragVerfasst: Do 05.10.06 18:58 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TBspKlasse.Loaded;
begin
DoCreate;
end;

Prima! Funzt! :zustimm: Danke.

_________________
Computer sind dumm, aber fleißig. Deshalb arbeite ich so gerne damit.
cuejo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP
Delphi 7 Personal und 2005 PE
BeitragVerfasst: Do 05.10.06 19:03 
Meinst du es wäre besser wenn ich noch inherited; dazuschreibe?

_________________
Computer sind dumm, aber fleißig. Deshalb arbeite ich so gerne damit.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.10.06 19:12 
Zitat:
Meinst du es wäre besser wenn ich noch inherited; dazuschreibe?
Meinst du im Konstruktor oder Loaded?

_________________
Markus Kinzler.
cuejo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP
Delphi 7 Personal und 2005 PE
BeitragVerfasst: Do 05.10.06 20:21 
user profile iconmkinzler hat folgendes geschrieben:
Meinst du im Konstruktor oder Loaded?

Im Konstruktor sowieso. Aber was ist mit Loaded? Ich hab's getestet und es funktioniert sowohl mit als auch ohne inherited.

_________________
Computer sind dumm, aber fleißig. Deshalb arbeite ich so gerne damit.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.10.06 20:22 
Loaded ist ja auch standardmäßig leeer.

_________________
Markus Kinzler.
cuejo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP
Delphi 7 Personal und 2005 PE
BeitragVerfasst: Do 05.10.06 20:27 
Achso. Na dann danke ich dir noch vielmals. Du hast mir sehr weitergeholfen. :D

_________________
Computer sind dumm, aber fleißig. Deshalb arbeite ich so gerne damit.