Autor Beitrag
Hochhäusl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57



BeitragVerfasst: So 18.07.04 11:03 
Hi,

ich will in eine image ein zufällig gewähltes bild laden ('z (34).bmp').

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
a: integer;
begin
randomize;
a:=random(50);
image1.Picture.LoadFromFile('C:\z ('+a+').bmp');


So funktioniert es jedoch noch nicht ganz. Wie kann man das machen?


Moderiert von user profile iconPeter Lustig: Code- durch Delphi-Tags ersetzt.
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: So 18.07.04 11:06 
Try this:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var
  a: integer;
begin
  randomize;
  a:=random(50);
  image1.Picture.LoadFromFile('C:\z (' + IntToStr(a) + ').bmp');
end;


beim weg: nimm doch das nächste mal einfach die [delphi] - Tags anstelle der [code] - Tags...

raziel

_________________
JSXGraph
Hochhäusl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57



BeitragVerfasst: So 18.07.04 15:37 
Danke, so funktionierts.

Und wie kann ich das selbe mit einer ressourcendatei machen???
So klappts nicht

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
a: integer;
begin
randomize;
a:=random(27);
Image1.Picture.Bitmap.Handle:=LoadBitmap(HINSTANCE,'d'+a);
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: So 18.07.04 15:55 
Dein Problem ist, dass Du String und Integer mixt, was aber in Delphi nicht direkt möglich ist! Du musst erst den Integer Wert per IntToStr in einen String Wert konvertieren, und das hab ich Dir oben bereits gezeigt!

raziel

//edit: Suche in: Delphi-Forum, Delphi-Library RESOURCE BITMAP oder gleich www.delphi-forum.de/viewtopic.php?t=98

_________________
JSXGraph