Autor Beitrag
Lemon
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: Di 09.03.04 20:00 
hallo,

ich habe auf meiner form 24 shapes. von shape1 bis shape24.
jetzt will ich ueber eine for schleife alle shapes ansprechen koennen.
d.h. der name des objekts besteht ja eigentlich aus 'shape' + i.
nur wie geht das, dass ich dann auch das objekt benutzen kann???
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Di 09.03.04 20:03 
Entweder per Array (dessen Objekte du zur Laufzeit erstellen musst) oder per Suche in: Delphi-Forum, Delphi-Library FINDCOMPONENT

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Jack Falworth
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 222

Win XP Pro, Slackware 10.0
D5 Enterprise, C++, ABAP
BeitragVerfasst: Mi 10.03.04 12:53 
bei so vielen komponenten ziehe ich persönlich die dynamische variante vor. Hier mal ein kurzer Ausschnitt wie man da vorgeht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
var
  shape: array[1..24] of TShape;

procedure TForm1.FormCreate(Sender: TObject);
var i: integer;
begin
 for i:= 1 to 24 do
  shape[i]:= TShape.Create (self);

 for i:= 1 to 24 do
 begin
  with shape[i] do
  begin
   parent:= form1;  // hier kann man die Eigenschaften der Shapes verändern.
   shape:= stcircle;  
   left:= 40;
   top:= 40;
   //...
  end;
 end;
end;


Der Vorteil: Man kann die Shapes über ein array verwalten!

MfG

Jack Falworth

_________________
Andere zu kritisieren ist mitunter eine Möglichkeit, sich selbst ins bessere Licht zu setzen.
Lemon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: Do 11.03.04 14:08 
danke.
hab' ne kombination beider vorschlaege benutzt.