Autor Beitrag
MaximusMR
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: So 25.05.03 09:35 
Ich möchte mir beliebig viele Objekte in mein Formular reinpacken können und nicht immer folgende zeile schreiben müssen
ausblenden Delphi-Quelltext
1:
2:
Sperre[1]:=Rect(Hindernis1.width ........);
Sperre[2]:=Rect(Hindernis2.width ........);

Sondern will ich
ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i:=1 to 40 do
 begin
   Sperre[i]:=Rect(Hindernis(((i))).width ......);
 end;

Mein Problem ist nur wie ich das i hinter Hindernis Variabel gestalte???
Hindernis1 ist der Name eines Objektes (bild z.B)
Sperre ist ein Arry.

PLZ HELP

Moderiert von user profile iconTino: Delphi-Tags hinzugefügt.
bis11
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: So 25.05.03 10:06 
So habe ich das gemacht aus Datensätzen, sollte aber vom Prinzip her auch mit einer FOR-Schleife funktionieren :
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:
begin                             
  button_top := firstbutton_top;                   
  with IBDataModule.IBQueryCategory do begin 
    Sql.Clear;                                                   
    Sql.Add('SELECT DISTINCT abteilung FROM auftrmgtconfig WHERE childnr>1;');  
    Open;       
    Active := true;
    while not EOF do begin   
      BasketButton := TSpeedButton.Create(self);  
      BasketButton.Parent := basketstrip;              
      BasketButton.left := firstbutton_left;              
      BasketButton.Top := button_top;                   
      BasketButton.Height := button_height;           
      BasketButton.Width := button_width;             
      BasketButton.Caption := Fields[0].AsString;   
      hDLL := LoadLibrary(PChar('ressource.dll'));  
      if hDLL <> 0 then begin                                
        try                                                            
          BasketButton.Glyph.LoadFromResourceName(hDLL,'neue');                
        finally                            
          FreeLibrary(hDLL);       
        end;
      end; 
      BasketButton.Name := Fields[0].AsString;    
      BasketButton.OnClick := BasketBtnClick;     
      button_top := button_top + 96;   
      next;                         
    end;                            
    Active := false;            
  end; 
end;


Das musste jetzt nur noch umbauen zu einer FOR-Schleife. Die While-Schleife funktioniert dort so ähnlich wie eine FOR-Schleife. Sie geht alle Datensätze durch und erstellt mir Buttons.
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: So 25.05.03 10:26 
Hi,
Versuchs mal mit FindComponent:
wenn Hindernis ein TImage ist:
ausblenden Quelltext
1:
TImage(FindComponent('Hindernis'+inttostr(i))).width					


mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
MaximusMR Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: So 25.05.03 10:40 
Wie bau ich das ein? zeig es mal bitte an meinem beispiel
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: So 25.05.03 10:57 
Also gut:
Meinetwegen ich habe 12 Buttons, alle heißen MyBtn1, MyBtn2, ... , MyBtn12. Ich möchte bei allen die Breite einstellen (auf 30 px).
Ich nehm mir also ein For-Schleife und durchlaufe jeden Button, spreche ihn mit FindComponent an und ändere seine Breite auf 30 px:
ausblenden Quelltext
1:
2:
for i := 1 to 12 do
TButton(FindComponent('MyBtn'+inttostr(i))).width := 30;


mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
MaximusMR Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Do 29.05.03 12:13 
Danke @GSE

So gehts!!!