Autor Beitrag
Gabel
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Mi 09.07.08 16:37 
Moin Moin
Ich habe ein Label auf einem Form das eine OnClick Procedure hat.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm2.Label1Click(Sender: TObject);
begin
onklick:=1;
end;


In der Laufzeit erstelle ich dann weitere Label's und will denn auch die selbe Procedure zuordnen.

ausblenden Delphi-Quelltext
1:
Zahl[n].OnClick:=TForm2.Label1Click;					

Habe jetzt langsam alle Delphi Foren durch und stundenlang Probiert.
Danke für eure Antworten.
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: Mi 09.07.08 16:43 
Hallo und :welcome: in der Entwickler-Ecke,

Wie ist den Zahl deklariert? Wenn das ein Array of TLabel ist, sollte das so in etwa funktionieren. Wie werden denn die Label erstellt? Und was ist überhaupt der Fehler, was funktioniert denn nicht?

_________________
We are, we were and will not be.
Gabel Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Mi 09.07.08 16:55 
Also die Zahlen werden wie folgend erstellt.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
Zahl: Array[1..150] of TLabel;
...
Zahl[n]:= Tlabel.create(Form2);
Zahl[n].Top := Punkt[n].Top + 10;
Zahl[n].Left := Punkt[n].Left + 10;
Zahl[n].Caption := s;
Zahl[n].Font.Name:='Arial';
Zahl[n].Transparent:=True;
Zahl[n].Parent := Form2


Das Programm kann ich nicht mal ausführen sondern es gibt gleich den Fehler:
ausblenden Delphi-Quelltext
1:
Inkompatible Typen:'TNotifyEvent' und 'Procedure'					


Gable
PeterPain
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 83



BeitragVerfasst: Mi 09.07.08 17:12 
user profile iconGabel hat folgendes geschrieben:
Moin Moin
Ich habe ein Label auf einem Form das eine OnClick Procedure hat.

ausblenden Delphi-Quelltext
1:
Zahl[n].OnClick:=TForm2.Label1Click;					



richtig wäre:

ausblenden Delphi-Quelltext
1:
  Zahl[n].OnClick := Form2.Label1Click;					


gruss
SAiBOT
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 323
Erhaltene Danke: 6

XP SP2; 7
D7; D2009
BeitragVerfasst: Mi 09.07.08 18:55 
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:
type
  TZeit = class(TTimer)
    procedure DoTimer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

procedure TZeit.DoTimer(Sender: TObject);
begin
  // tu was
end;

var
  Timer1: TZeit;
begin
  Timer1 := TZeit.Create(nil);
  Timer1.Interval := 1000;
  Timer1.OnTimer := Timer1.DoTimer;
  Timer1.Enabled := True;
end.


So gehts' auch :wink:
Gabel Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Mi 09.07.08 22:24 
Jo geht bis her ganz gut.
Habe aber noch ne kleine Frage.
Ich mache das ja bei eine mehreren Label, wie kann die Procedure jetzt wissen wellchen N label grade angeklickt wird.


Danke Gabel
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 09.07.08 22:27 
Moin und :welcome: im Forum!

user profile iconGabel hat folgendes geschrieben:
Habe aber noch ne kleine Frage.
Ich mache das ja bei eine mehreren Label, wie kann die Procedure jetzt wissen wellchen N label grade angeklickt wird.
Normalerweise: neue Frage, neues Topic! :idea:

Ausnahmsweise noch hintendran: du kannst die Eigenschaft .Tag der Labels beim Erstellen verwenden, um dem betreffenden Label den Index mitzugeben. In der OnClick-Methode kannst du dann dort den Index abfragen. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mi 09.07.08 22:29 
Alternativ müsste das auch über die Variable Sender gehen. :)
Wobei es wohl doch etwas umständlicher als mit Tags ist. :?