Autor Beitrag
sebastiansorglos
Hält's aus hier
Beiträge: 12



BeitragVerfasst: Mi 30.03.05 10:48 
bin delphi-neuling mein quellcode:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TFahrstuhl.Timer1Timer(Sender: TObject);
         begin         {Station 1}
          with Station1.canvas do begin
          pen.Width := 150;
          ...

da ich die procedur mehrmals durchführen muss, wollte ich ganz gerne statt Station1.canvas igendwie Station[X].canvas sagen und X dann halt hochzählen.
geht das und wenn ja wie???
es soll etwas in das vorhandene TImage gezeichnet werden!

mfg sebastian


Zuletzt bearbeitet von sebastiansorglos am Mi 30.03.05 11:19, insgesamt 1-mal bearbeitet
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: Mi 30.03.05 10:52 
Also erstmal :welcome: im DF!!! ;)

Dann: Mach mal deinen Code in Delphi-Tags rein. Einfach rechts oben bei deinem Beitrag auf das "Scheren-Ding" klicken und dann reineditieren. Danke. ;)

Und jetzt zum Prob: Das was du willst heißt Array. Dazu musst du aber erstmal wissen, was dein "Station" ist. Also z.B. ein Button (was ich hier mal nicht vermute). Eher ein TImage, oder??
sebastiansorglos Threadstarter
Hält's aus hier
Beiträge: 12



BeitragVerfasst: Mi 30.03.05 11:00 
ja TImage!
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Mi 30.03.05 11:22 
Also du könntest entweder ein array of TImage benutzen, dazu müsstest du die Images Suche in: Delphi-Forum, Delphi-Library "DYNAMISCH ERZEUGEN", oder du nimmst die Suche in: Delphi-Forum, Delphi-Library "FINDCOMPONENT"-Methode, mit der kannst du den Namen zur Laufzeit zusammenbasteln und dann die entsprechende Komponente finden.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
sebastiansorglos Threadstarter
Hält's aus hier
Beiträge: 12



BeitragVerfasst: Mi 30.03.05 11:53 
danke für die tipps!
hab aber trotzdem noch probleme bei der realisierung mit der FindComponent methode die andere hab ich noch nicht probiert!
bringt mir die fehlermeldung "undefinierter bezeichner" aus bei moveto-zeile!
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
  const
  Station = 'Station';
  canvas = '.canvas';

begin
  for i := 1 to 3 do begin
    {TImage.Create(Self).Name := Station + IntToStr(i) + canvas;}
    with FindComponent(Station + IntToStr(i) + canvas ) {station1.canvas} do
    begin
      label1.Caption := (Station + IntToStr(i) + canvas );
      moveto (1,1);
      lineto (10,10);
      Left := 10;
      Top := i * 20;
      Parent := self;
    end;
  end;
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: Do 31.03.05 09:07 
So sollte es klappen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
  const
  Station = 'Station';
  canvas = '.canvas';

begin
  for i := 1 to 3 do begin
    {TImage.Create(Self).Name := Station + IntToStr(i) + canvas;}
    with TImage(FindComponent(Station + IntToStr(i) + canvas )) {station1.canvas} do
    begin
      label1.Caption := (Station + IntToStr(i) + canvas );
      moveto (1,1);
      lineto (10,10);
      Left := 10;
      Top := i * 20;
      Parent := self;
    end;
  end;

Woher soll denn auch Findcomponent wissen, dass es da ein Bild gefunden hat? :wink:

_________________
We are, we were and will not be.
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: Do 31.03.05 09:11 
Und die ' sollte man auch nicht vergessen:

ausblenden Delphi-Quelltext
1:
with TImage(FindComponent('Station' + IntToStr(i) + canvas )) {station1.canvas} do					

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
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: Do 31.03.05 09:14 
@GTA-Place: Hab ich zuerst auch gedacht, aber dafür hat er ja Variablen eingeführt. Über den Sinn dieser kann man sicherlich streiten, aber es geht. :roll:

_________________
We are, we were and will not be.
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: Do 31.03.05 10:10 
Aufgrund einer PN, die besagt, dass das immer noch nicht klappt, probier das mal:
ausblenden Delphi-Quelltext
1:
2:
with TImage(FindComponent(Station + IntToStr(i))).canvas  do   
begin

Also: Erst das TImage finden, und mit dessen Canvas arbeiten.

_________________
We are, we were and will not be.
sebastiansorglos Threadstarter
Hält's aus hier
Beiträge: 12



BeitragVerfasst: Do 31.03.05 12:25 
ja so geht es, danke Gausi!!!