Autor Beitrag
TheRealHoddy
Hält's aus hier
Beiträge: 11

Win XP
Delphi 7
BeitragVerfasst: Mo 20.03.06 00:08 
Ich bins nochmals,

kann mir einer sagen wie ich ein Label in einer Funktion aufrufen kann?

hier das Problem:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
if Zahl=1 then
       begin
          TForm1.Label1Click;
       end
     else if Zahl=2 then TForm1.Label2Click;


hoffe hier is noch jemand wach :P

lg hoddy

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Mo 20.03.06 00:13 
du hasts doch schon fast selber :)
einfach code vervollständigung benutzen nachdem du label1. eingebeben hast dann sticht dir das onclick ins auge und du hängst noch irgend einen paramter (sollte ein Objekt sein) ran z.b.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
if Zahl=1 then 
begin 
Form1.Label1.OnClick(Button1); 
end 
else if Zahl=2 then Form1.Label2.OnClick(Button1);
TheRealHoddy Threadstarter
Hält's aus hier
Beiträge: 11

Win XP
Delphi 7
BeitragVerfasst: Mo 20.03.06 00:17 
hehe vielen Dank!

und eine Gute Nacht! :wink:
liquid air
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 76



BeitragVerfasst: Mo 20.03.06 00:24 
wenn ich noch was dazufügen darf: falls du es doch so machen willst wie du am anfang geschrieben hast, musst du einfach nur jeweils bei type und nach dem {$R *.dfm}, wo du die prozedur tform1.label1Click deklarierst, das "(Sender: TObject)" löschen, und dann kannste einfach schreiben

ausblenden Delphi-Quelltext
1:
2:
3:
if zahl=1 then begin
 label1Click;
end;


is vllt n bissl umständlicher, aber ich will auch mal jemandem helfen und nich nur selber fragen stellen ^^'
TheRealHoddy Threadstarter
Hält's aus hier
Beiträge: 11

Win XP
Delphi 7
BeitragVerfasst: Mo 20.03.06 00:31 
hehe ich las mir gern helfen :P

aber guter tipp, kann ich bestimmt nochma gebrauchen!
liquid air
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 76



BeitragVerfasst: Mo 20.03.06 00:35 
hehe na dann is ja gut :P

hab gern geholfen :D
Benutzername
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 210

Win XP Pro
Delphi 7 PE, D2005 Prof. SSL
BeitragVerfasst: Mo 20.03.06 21:38 
Besser wärs, wenn du den Code, der im Label-OnClick ausgeführt wird, in eine eigene Prozedur/Funktion auslagerst und diese dann sowohl im Label-OnClick als auch in deinem anderen Code aufrufst:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
if Zahl=1 then   
       begin   
          MeineLabel1Prozedur;   
       end   
     else if Zahl=2 then MeineLabel2Prozedur;