Autor Beitrag
4r4k1s
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Mi 03.01.07 17:28 
Habe mehrere Buttons während des PRogrammes erzeugt nun möchte ich wissen wie man feststellen kann auf welchen Button ich geklickt habe.
wenn ich zum beispiel auf einer der button klicke das der dann verschwindet oder ein 'X' drin steht.
Was auch cool wäre wenn man die Buttons farbig markieren könnte.

Möchte also wissen ob man das realisieren kann und wie?!!!!?


Moderiert von user profile iconGausi: Topic aus Sonstiges (Delphi) verschoben am Mi 03.01.2007 um 16:32
aim65
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 312

Win 9x, Win XP
Delphi 3pro, 7PE
BeitragVerfasst: Mi 03.01.07 17:41 
Guck Dir mal SpeedButton und dort GroupIndex an. Vielleicht ist es das was Du brauchst.
4r4k1s Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Mi 03.01.07 17:47 
danke erstmal für die schnelle antwort...

leider brauche ich keine gruppierung der buttons sondern ich möchte wissen wie man feststellt ob und welcher button gedrückt ist..

die buttons habe ich aber erst später erzeugt...
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 03.01.07 17:51 
Hast du den Buttons eine OnClick-Prozedur zugewiesen? Über den Paramter Sender bekommt man raus, welcher Button geklickt wurde:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Button1Und2Click(Sender: TObject);
begin
 if (Sender as TButton) = Button1 then
  Showmessage('Button 1 geklickt')
 else
  Showmessage('Button 2 geklickt');
end;


Natürlich muss bei Button1 und Button2 diese Prozedur bei OnClick eingetragen werden.

_________________
We are, we were and will not be.
4r4k1s Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Mi 03.01.07 17:55 
Das problem is aber das ich die buttons erst erzeuge wenn das programm ja schon läuft vorher sind die ja nicht da.
Und wie kann ich dann bei noch nicht erzeugten Buttons solch eine funktion zuweisen ??

außerdem sind das 200 buttons müsste ich dann jeden einzelnen button diese Funktion zuweisen ??
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 03.01.07 18:02 
Wenn die Buttons gleichmäßige Namen haben, hilft FindComponent. Das Zuweisen geht dann so:
ausblenden Delphi-Quelltext
1:
2:
for i := 1 to 10 do
  TButton(FindComponent('Button' + IntToStr(i))).Onclick := Button1ClickUnd2;

_________________
We are, we were and will not be.
4r4k1s Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Mi 03.01.07 18:07 
also das meiste ist eigentlich soweit klar aber was macht das Button1ClickUnd2;?

und was ich glaube vergessen habe wir haben 2 dimensionale buttons also wir sprechen die über button[1,4] oder button[2,8] an geht das dann auch so oder müsste man was ändern?
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 03.01.07 18:13 
Das ist die Prozedur aus meinem vorigen Post. Oder halt die Onclick-Prozedur, die du da verwendest. Wenn du ein Button-Array hast, muss du einfach ne doppelte Schleife nehmen. Ich gehe mal davon aus, dass du das mit 2dimensionalen Buttons meinst :)

ausblenden Delphi-Quelltext
1:
2:
3:
for x := 1 to 10 do
  for y := 1 to 10 do
    Button[x,y].OnClick := MeineVorbeiteteOnClickProcedure;

_________________
We are, we were and will not be.
4r4k1s Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Mi 03.01.07 18:21 
danke das wars echt cool von euch das ihr so schnell geantwortet habt...

damit ist meine frage beantwortet