Autor Beitrag
Kaeawc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41



BeitragVerfasst: Mo 27.03.06 20:42 
Ich habe insgesamt 10 Bilder in meinem Formular. Sobald man das Formulat öffnet soll eins von den 10 Bildern durch Zufall erscheinen. Wie ist dies machbar?
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mo 27.03.06 20:47 
du könntest deine 10 Bilder in ein Array packen.
Mit BildArray[Random(10)].show; müsste sich dann ein zufälliges bild anzeigen lassen :roll:


Zuletzt bearbeitet von Marc. am Mo 27.03.06 20:47, insgesamt 1-mal bearbeitet
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: Mo 27.03.06 20:47 
einfachste lösung, die mir spontan einfällt:
pfade zu bildern in ne stringlist,
random(9)+1
entsprechende zeile aus stringgrid nehmen und datei laden...
Kaeawc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41



BeitragVerfasst: Mo 27.03.06 20:49 
habe noch nie mit string oder array gearbeitet.. könnte mir vllt jemand den code schreiben? wäre sehr nett
Müscha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118



BeitragVerfasst: Mo 27.03.06 20:49 
alle Bilder visible:=false setzen

auf Form doppelklicken

dann dort

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
randomize;

Zahl:= Random(10)+1;




case Zahl of

1: image1.visible:=true;
2: image2.visible:=true;
3: image3.visible:=true;
4: image4.visible:=true;
5: image5.visible:=true;
6: image6.visible:=true;
7: image7.visible:=true;
8: image8.visible:=true;
9: image9.visible:=true;
10: image10.visible:=true;

end;


das dürfte funktionieren :)

Gruß Müscha



edit: Es funktioniert!!!!!!!!!!!!!!!!! 8)

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt
Kaeawc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41



BeitragVerfasst: Mo 27.03.06 21:02 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.Button1Click(Sender: TObject);
randomize;
Zahl:= Random(9)+1;
begin
case Zahl of
1: image1.visible:=true;
2: image2.visible:=true;
3: image3.visible:=true;
4: image4.visible:=true;
5: image5.visible:=true;
6: image6.visible:=true;
7: image7.visible:=true;
8: image8.visible:=true;
9: image9.visible:=true;


[Fehler] Unit1.pas(38): Unbekannte Anweisung: 'Zahl'
[Fehler] Unit1.pas(40): Undefinierter Bezeichner: 'Zahl'
[Fehler] Unit1.pas(37): Unbekannte Anweisung: 'randomize'

Ich bin zu blöd um das einzufügen *hust* :S

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mo 27.03.06 21:03 
liegt wohl daran, dass er
ausblenden Delphi-Quelltext
1:
2:
3:
var
 zahl: byte;
begin


vergessen hat :mrgreen:
Kaeawc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41



BeitragVerfasst: Mo 27.03.06 21:05 
Alles funktioniert, super, thx für die schnelle Hilfe :))
Müscha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118



BeitragVerfasst: Mo 27.03.06 21:05 
also

ausblenden Quelltext
1:
2:
3:
var  zahl:integer;

begin;


hab ich genommen, keine Ahnung, ob byte jetzt besser ist!!!
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mo 27.03.06 21:06 
Oder einfacher:
TImage(FindComponent('Image' + IntToStr(Random(9) + 1))).Visible := True; :mrgreen:

greetz


EDIT: Davor muss aber noch Randomize; ;) oder bei FormCreate

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Müscha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118



BeitragVerfasst: Mo 27.03.06 21:08 
das hat mich schon lange mal interressiert,

wie funktioniert TImage?


muss ich da irgendwo noch ne Komponente einbauen?
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mo 27.03.06 21:08 
user profile iconMüscha hat folgendes geschrieben:
das hat mich schon lange mal interressiert,

wie funktioniert TImage?


muss ich da irgendwo noch ne Komponente einbauen?


Das sind doch alles TImages, oder was meinst du?

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mo 27.03.06 21:10 
user profile iconMüscha hat folgendes geschrieben:
also
ausblenden Quelltext
1:
2:
var  zahl:integer;
begin;

hab ich genommen, keine Ahnung, ob byte jetzt besser ist!!!



ich habe byte gewählt, weil die du ja gerade mal einen wert von max. 9 hast! Einen Integer zu verwenden wäre in diesem fall platzverschwendung :D
Müscha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118



BeitragVerfasst: Mo 27.03.06 21:14 
naja, ich dachte da gibts sowas, wo man irgendwie paar Bilder hinspeichern kann und die dann mit irgendeinem Abruf einzeln auswählen kann, ohne dass man alle Images auf die Form bringen muss.


Und das mit dem Speicherplatz, bringt das wirklich einen so großen Unterschied?
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mo 27.03.06 21:16 
user profile iconMüscha hat folgendes geschrieben:
naja, ich dachte da gibts sowas, wo man irgendwie paar Bilder hinspeichern kann und die dann mit irgendeinem Abruf einzeln auswählen kann, ohne dass man alle Images auf die Form bringen muss.


Du meinst TImageList ;)

Aber das was ich da gepostet hab, was dafür, wenn er alle Imnages auf der Form hat...


greetz

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Müscha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118



BeitragVerfasst: Mo 27.03.06 21:22 
genau :D

und kannst du mir das innerhalb von 3/4 Sätzen erklären?

mach zur zeit nen quiz und hab da 15 Bilder übereinander, das is auch noch nich so das beste!

also das Symbol TImageList hab ich schon auf der Form, aber ich finde da nix wo man die Bilder reinladen kann.
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mo 27.03.06 22:28 
Na klar:

Also wenn du mal die Kompo auf deine Form ziehst und rechte Maustaste drauf macht dann wähle mal das erste aus (heißt Bildlisten-Editor oder so). Da kannst du deine ganzen Bilder dann einfügen und um sie in ein Image zu laden hier mal ein Beispiel: ImageList1.GetBitmap(0 { beginnend bei 0 ;) }, Image1.Picture.Bitmap)


greetz

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Müscha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118



BeitragVerfasst: Mi 29.03.06 19:54 
Cool danke, hab nur das Problem dass die Bilder nur sehr sehr klein angezeigt werden, wo kann man das ändern?
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mi 29.03.06 20:02 
Kannst du IMO auch in dem Editor einstellen ;)


greetz

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Müscha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118



BeitragVerfasst: Mi 29.03.06 20:11 
naja da gibts ja nich viele Möglichkeiten, wo genau kann man das einstellen?

da gibts:

Hinzufügen ersetzen löschen entfernen exportieren

Transparent Füllfarbe

Optionen : Zuschneiden, Drehen Zentrieren

Ok Abbrechen Übernehmen und Hilfe


aber nix was die einstellung von der größe ändert...