Autor Beitrag
orakel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 92

Win XP

BeitragVerfasst: Sa 21.02.04 14:17 
Hallo,
Ich möchte beim Klick von Button1:
1. einen neuen Button erstellen
2.eine neue Form erstellen

Ich möchte diese aber immer Zusammen in einem eigenen Type haben. Hier mein bisheriger Quelltext:

ausblenden volle Höhe 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:
28:
29:
30:
31:
32:
33:
34:
35:
type
    TBenutzer=record
     Button:TButton;
     Fenster:TForm;
end;
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Beiklick(Sender: TBenutzer);

.....

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var M: TForm;
    T: TButton;
    N:TBenutzer;
begin
 N.Fenster:=TForm.Create(Form1);
 N.Button:=TButton.Create(Form1);
 N.Button.Parent:=Form1;
 N.Button.OnClick:=Form1.BeiKlick(N);  //Fehlermeldung!!(s.u.)
end;

procedure TForm1.BeiKlick(Sender:TBenutzer);
var Benutzer:TBenutzer;
begin
 Benutzer:=TBenutzer(Sender);
 Benutzer.Fenster.Show;
end;

end.


Jedesmal tritt aber folgende Fehlermeldung auf:
Incompatible types:
Zitat:
’NotifyEvent’ and ‘procedure, untyped Pointer or untyped parameter’


Warum?

_________________
Nicht verzagen, orakel fragen!
mirage228
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 338

Win 7 Prof.
Delphi 2005 Prof., Delphi 2010 Prof.
BeitragVerfasst: Sa 21.02.04 14:23 
Schau dir mal TNotifyEvent an:

ausblenden Delphi-Quelltext
1:
2:
type
  TNotifyEvent = procedure(Sender: TObject) of object;
.

Du musst also bei Sender nicht TBenutzer sondern TObject schreiben. In der Prozedure selbst kannst du ja casten.

mfG
mirage228

_________________
May the source be with you, stranger.
orakel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 92

Win XP

BeitragVerfasst: Sa 21.02.04 14:33 
Ich versteh nicht ganz, wie du das meinst.
Könntest du mal zeigen, wie das in meinem Fall dann aussehen sollte?

Andi

_________________
Nicht verzagen, orakel fragen!
mirage228
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 338

Win 7 Prof.
Delphi 2005 Prof., Delphi 2010 Prof.
BeitragVerfasst: Sa 21.02.04 14:55 
Hi,

die Prozedur sollte so aussehen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.BeiKlick(Sender: TObject); 
var Benutzer:TBenutzer; 
begin 
 Benutzer := TBenutzer(Sender); 
 Benutzer.Fenster.Show; 
end;


mfG
mirage228

_________________
May the source be with you, stranger.
orakel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 92

Win XP

BeitragVerfasst: Sa 21.02.04 15:26 
Und wie sieht dann folgende Zeile aus?

ausblenden Delphi-Quelltext
1:
 N.Button.OnClick:=Form1.BeiKlick(N);					

so?
ausblenden Delphi-Quelltext
1:
N.Button.OnClick:=Form1.BeiKlick(N) of TBenutzer					


Andi

_________________
Nicht verzagen, orakel fragen!
mirage228
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 338

Win 7 Prof.
Delphi 2005 Prof., Delphi 2010 Prof.
BeitragVerfasst: Sa 21.02.04 15:41 
Nene, die bleibt so wie die ist. Du musst nur die Deklaration der Prozedur selbst verändern (also TObject statt TBenutzer beim Parameter)

mfG
mirage228

_________________
May the source be with you, stranger.