Autor Beitrag
mega
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46

Win XP
D3 Prof
BeitragVerfasst: Sa 09.04.05 19:03 
Button-Array (Buttons über Index ansprechen; Button[i]:= ..)

Hallo,

Kann man Butons zu einem Array machen?
Es gibt mehrere Buttons zur Auswahl Tetrisähnlicher Spielsteine, die Drch druck auf den Entsprechenen Knopf gewählt werden.

In der dann gerufenen Ablegeprocedur soll dann am Schluß ausgeführt werden:
Button[i].visible := false
Aber nur wenn der Stein auch abgelegt wurde und nicht doch ein andere gewählt wurde.
Das Problem ist jetzt nur, wie man die Buttons in ein Array packt.


Moderiert von user profile iconraziel: Topic aus Sonstiges verschoben am Sa 09.04.2005 um 20:07
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Sa 09.04.05 19:08 
Ja, das ist möglich. Dazu musst du sie aber zur Laufzeit erstellen. Einfach mal die Forensuche verwenden. Oder du suchst nach Suche in: Delphi-Forum, Delphi-Library FINDCOMPONENT

;)
wdbee
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 628
Erhaltene Danke: 1



BeitragVerfasst: Sa 09.04.05 19:12 
Oder auch so:
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:
type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    ButtonN: TButton;
    procedure FormCreate(Sender: TObject);
  private
    MyButtons: array [1..N] of TButton;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  MyButtons[1] := Button1;
  MyButtons[2] := Button2;
  ...
  MyButtons[N] := ButtonN;
end;
mega Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46

Win XP
D3 Prof
BeitragVerfasst: Sa 09.04.05 22:35 
user profile iconwdbee hat folgendes geschrieben:
Oder auch so:

Danke.

Werde es probieren
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: So 10.04.05 08:58 
Nimm FindComponent(). Ist viel einfacher.

ausblenden Delphi-Quelltext
1:
TButton(Form1.FindComponent('Button' + IntToStr(X))).Caption := 'bla...';					

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
wdbee
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 628
Erhaltene Danke: 1



BeitragVerfasst: So 10.04.05 10:05 
@GTA-Place: ... und viel langsamer! :D