Autor Beitrag
MSC
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 63

Win XP Home, Win Vista Buisiness
Delphi 7 Enterprise
BeitragVerfasst: So 17.09.06 00:01 
Hi! Bin neu hier.

Ich habe ein Problem:
Wenn ich nen Butten1 klicke soll in einem Image ein bmp 1 erscheinen.
Und wenn ich Button2 klicke soll bmp 2 erscheinen ect.

Ich möchte es umgehen, einzelne Image für jedes Bild, weil ich sonst vorraussichtlich tausende Images brauche, und die dann einzeln Visible True/False machen muss.

Bzw. möchte ich über einen Timer eine art Animation erreichen, der dann verschidene Bilder nacheinander in einem Image Element anzeigt.
Oder ist da Image nicht das richtige, und ich sollte etwas anderes nehmen, was auch BMP anzeigen kann und mit transparenter Farbe arbeiten kann?

Könnte mir da jemand helfen? :)
Masterhawk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 92

Win 2000,Win XP
D6 Pers
BeitragVerfasst: So 17.09.06 00:24 
:welcome:

also, du könnest des so machen...
ausblenden volle Höhe Delphi-Quelltext
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:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    Bmp1:TBitmap; //Bild1
    Bmp2:TBitmap; //Bild2
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Bmp1:TBitmap.create;              //Bild1 erstellen
  Bmp1.LoadFromFile('deinBild.bmp');// und laden

  Bmp2:TBitmap.create;               //Bild2 erstellen
  Bmp2.LoadFromFile('deinBild2.bmp');// und laden
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 image1.Picture.Assign(Bmp1); //Bild1 ins Image1 laden
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  image1.Picture.Assign(Bmp2); //Bild1 ins Image1 laden
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Bmp1.Destroy; //Bild1 freigeben
  Bmp2.Destroy; //Bild2 freigeben
end;

end.


Ich hoffe das hilft dir erstmal weiter....sry, aber Code ist net getestet....

MfG Masterhawk
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: So 17.09.06 00:24 
Hallo !
Hier mal ein kleines Bsp. vieleicht hilft Dir das weiter.
ausblenden Delphi-Quelltext
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:
public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  i:Integer;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  i:=0{Zähler zurücksetzen}
  Timer1.Enabled:= not Timer1.Enabled; {Timer an bzw. ausstellen}
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  inc(i); {Hochzählen}
  if i > 3 then Timer1.Enabled:=False; {Wenn Bild vier erreicht Timer austellen}
  Image1.Picture.LoadFromFile(ExtractFilePath(ParamStr(0))+ 'Bild' + IntToStr(i) +'.bmp'); {Bilder nach einander laden (Die Bilder müssen in dem Ordner deiner Exe liegen und Bild1, Bild2 usw. heißen)}
end;

end.
MSC Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 63

Win XP Home, Win Vista Buisiness
Delphi 7 Enterprise
BeitragVerfasst: So 17.09.06 02:27 
Titel: jo, klappt
Vielen Dank!

So hab ich mir das vorgestellt.
Zumal auch die Möglichkeit offen ist, die Bilder zu ändern, und per Variablen zu laden.
Auch ein wechseln der Bilder im laufenden Programm ist möglich (andere Bilder laden).

Allerdings ist es möglich über try, ecept abzufragen, ob die dateien vorhanden sind?
Weil wenn die nicht da sind, lässt sich das Prog nicht beenden. (nur per Strg + F2)
Xion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
EE-Maler
Beiträge: 1952
Erhaltene Danke: 128

Windows XP
Delphi (2005, SmartInspect), SQL, Lua, Java (Eclipse), C++ (Visual Studio 2010, Qt Creator), Python (Blender), Prolog (SWIProlog), Haskell (ghci)
BeitragVerfasst: So 17.09.06 10:03 
hi
probiers mal mit FileExists

ausblenden Delphi-Quelltext
1:
2:
if FileExists('MeineDatei.exe'then
 //Mach was mit der Datei

_________________
a broken heart is like a broken window - it'll never heal
In einem gut regierten Land ist Armut eine Schande, in einem schlecht regierten Reichtum. (Konfuzius)
MSC Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 63

Win XP Home, Win Vista Buisiness
Delphi 7 Enterprise
BeitragVerfasst: So 17.09.06 13:03 
Titel: Geht
Ok funtz!
Thanks :)