Autor Beitrag
Ke-chan
Hält's aus hier
Beiträge: 4



BeitragVerfasst: So 19.06.05 14:39 
In dem Programm, was ich z.Z. schreiben muss, ist folgendes Problem entstanden:
In einer selbst erstellten Procedure sol in einem Image ein Bild hoch geladen werden.
Beim Complimeiren sagt er mir aber *Undefinierter Bezeichner 'Image1'*
Ich schätze man muss ihm irgendwie sagen, dass er auf die Image-objekte in Form1 zugreifen soll.
Kann mir jemand sagen, wie ich das umsetzen soll?

Hier noch der Programmabschnitt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
{var z,a: array[1..9] of integer;}

procedure laden(z,a: array of integer);
begin
  Image1.Picture.LoadFromFile(a[z[1]]);
  Image2.Picture.LoadFromFile(a[z[2]]);
  {etc.}
end;

Mir würde es auch helfen, wenn mir jemand sagen kann, ob und wie man 'Image1' als Variable in dem zus.hang darstellen kann, so dass er dann auch in das jeweilige Imagefeld das Bild lädt.
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: So 19.06.05 14:44 
Probier doch einfach mal

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure laden(z,a: array of integer);
begin
  Form1.Image1.Picture.LoadFromFile(a[z[1]]);
  Form1.Image2.Picture.LoadFromFile(a[z[2]]);
  {etc.}
end;


;)
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: So 19.06.05 14:46 
das ist ganz einfach. 2 methoden:
1. Schau dir die Typendeklaration von der Form an. du findest einen teil "public" und "private" usw.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
type
  TForm1 = class(TForm)
    Image1:TImage;
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

Schreibe in eines von beiden den Prozedurenkopf:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    procedure laden(z,a: array of integer);
    { Public-Deklarationen }
  end;

und nun schreibe unten bei deiner prozedur ein TForm1. davor:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.laden(z,a: array of integer);   
begin   
  Image1.Picture.LoadFromFile(a[z[1]]);   
  Image2.Picture.LoadFromFile(a[z[2]]);   
  {etc.}   
end;

Das wars.
2.:
Schreibe ein with Form1 do begin davor. (nicht so gut, das aufrufen der prozedur kann probleme machen)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure laden(z,a: array of integer);   
begin
with Form1 do
 begin   
  Image1.Picture.LoadFromFile(a[z[1]]);   
  Image2.Picture.LoadFromFile(a[z[2]]);   
  {etc.}   
 end;
end;{ODER:}
procedure laden(z,a: array of integer);   
begin   
  Form1.Image1.Picture.LoadFromFile(a[z[1]]);   
  Form1.Image2.Picture.LoadFromFile(a[z[2]]);   
  {etc.}   
end;


edit: mist.. zu langsam ^^ aber ausführlicher ^^

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
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: So 19.06.05 14:48 
user profile iconJayEff hat folgendes geschrieben:
edit: mist.. zu langsam ^^ aber ausführlicher ^^

Aber echt. Das könntest du ja fast als Tutorial nehmen... :flehan: ;)
Ke-chan Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: So 19.06.05 15:38 
Danke euch!
So geht's *freu*
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: So 19.06.05 15:40 
user profile iconKe-chan hat folgendes geschrieben:
Danke euch!
So geht's *freu*

Kein Problem. ;)