Habe folgendes Problem!
Habe sechs Bilder und die soll'n Zufällig gewählt werden das klappt ja.
das sind Würfel, also bei 0 wäre es das Bild mit der Eins usw.
Das mit dem Label hab ich nur eingebaut um zu sehen welche zufallsvariable grad erzeugt wurde,und ob das klappt.
Jetzt mein Problem
Ich möchte gern bei Image.klick das ich weiss welches Bild gerade da ist,so wie ich das hier gemacht habe erkennt er nur 0 oder 1 irgendwie muss ich die Variable an die Image.klick Methode übergeben aber wie ?
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: 32: 33: 34: 35: 36: 37: 38:
| procedure TForm1.Button1Click(Sender: TObject); var a: integer; begin randomize; a:=Random(6);
if a=0 then Label1.Caption:='1'; if a=1 then Label1.Caption:='2'; if a=2 then Label1.Caption:='3'; if a=3 then Label1.Caption:='4'; if a=4 then Label1.Caption:='5'; if a=5 then Label1.Caption:='6';
if a=0 then image1.Picture.LoadFromFile(ExtractFilePath(paramStr(0)) + '1.bmp'); if a=1 then image1.Picture.LoadFromFile(ExtractFilePath(paramStr(0)) + '2.bmp'); if a=2 then image1.Picture.LoadFromFile(ExtractFilePath(paramStr(0)) + '3.bmp'); if a=3 then image1.Picture.LoadFromFile(ExtractFilePath(paramStr(0)) + '4.bmp'); if a=4 then image1.Picture.LoadFromFile(ExtractFilePath(paramStr(0)) + '5.bmp'); if a=5 then image1.Picture.LoadFromFile(ExtractFilePath(paramStr(0)) + '6.bmp');
procedure TForm1.Image1Click(Sender: TObject); begin if a=0 then image2.Picture.LoadFromFile(ExtractFilePath(paramStr(0)) + '1.bmp'); end; |
Moderiert von
Peter Lustig: Topic verschoben