Autor Beitrag
Unknown
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 184

Win XP
Delphi 7
BeitragVerfasst: Mo 25.06.07 13:13 
Hallo,
wie kann ich ein Image createn, dass die gleichen "Sachen" wie mein vorhandenes Image1 hat....

P.S: gibt es ein Befehl, der herrausfindet ob ein Image existiert, z.B: If Image1.exist oder so
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 25.06.07 14:08 
Moin!

user profile iconUnknown hat folgendes geschrieben:
wie kann ich ein Image createn, dass die gleichen "Sachen" wie mein vorhandenes Image1 hat....

Glaskugel hat folgendes geschrieben:
Warning: please check query syntax!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var
  Bitmap: TBitmap;
begin
  Bitmap := TBitmap.Create;
  Bitmap.Assign(Image1.Picture.Bitmap);


user profile iconUnknown hat folgendes geschrieben:
P.S: gibt es ein Befehl, der herrausfindet ob ein Image existiert, z.B: If Image1.exist oder so

Glaskugel hat folgendes geschrieben:
Warning: please check query syntax!

Suche in: Delphi-Forum, Delphi-Library FINDCOMPONENT

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Unknown Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 184

Win XP
Delphi 7
BeitragVerfasst: Mo 25.06.07 14:25 
ich glaube ich hab meine Frage falsch formuliert:
Für ein Image hab ich das geschrieben:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
// Hier müsste das mit
// If Image.exist then begin
IF Image1.Left<150 then exit
 else Image1.Left:=Image1.Left-5;
//end;   weil sonst ein Fehler kommt: es existiert kein Image, weil alle zerstört wurden
end;

procedure TForm1.Image1Click(Sender: TObject);
begin
Image1.Destroy;
end;


Und in eineme anderen Timer will ich, dass mehrere Images davon createt werden.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 25.06.07 14:28 
Moin!

Ist die Anzahl der Images zur Laufzeit variabel oder ist die Menge konstant?

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Unknown Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 184

Win XP
Delphi 7
BeitragVerfasst: Mo 25.06.07 14:42 
Variabel
Jann1k
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 866
Erhaltene Danke: 43

Win 7
TurboDelphi, Visual Studio 2010
BeitragVerfasst: Mo 25.06.07 14:49 
Dann musst du die Images entweder irgendwo speichern (List, array, imagelist) oder du nummerierst die Namen der Images durch, damit du sie mit findcomponent und einer Schleife alle finden kannst.

Zweig mal die Stelle im Quelltext wo du deine Images erzeugst.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 25.06.07 14:50 
Moin!

OK, Ansatz:
- globale TObjectList anlegen und die Images mit Ower=NIL createn (Parent dann auf das Formular setzen) und dann in der Liste sammeln
- wenn du ein Image nicht mehr brauchst, einfach aus der TObjectList entfernen, wird dann automatisch freigegeben.

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Unknown Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 184

Win XP
Delphi 7
BeitragVerfasst: Mo 25.06.07 15:12 
@Narses:
meinst du etwa so www.dsdt.info/tutori.../tobjectlist/?page=2

Edit1: vll hilft euch das: im meinem Prog sollen Images von rechts nach links fliegen, ich muss sie abschießen. Und wenn sie angekommen sind sollen sie einfach stehen bleiben....

Edit2:@ Jan1k diese Stelle habe ich ja noch nicht, da ich nicht weiß, wie man ein Image erstellt mit den gleichen "Sachen" wie ein anderes

Edit3:Das mit ObjectList funzt bei mir net :-(
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
var
  Form1: TForm1;
  Objectlist: TObjectList;   //[Error] Unit1.pas(21): Undeclared identifier: 'TObjectList'

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
ObjectList := TObjectList.create;
ObjectList.OwnsObjects := true;
end;

procedure TForm1.Frmdestroy(Sender: TObject);
begin
ObjectList .free;
end;

end.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 25.06.07 15:29 
Moin!

user profile iconUnknown hat folgendes geschrieben:
meinst du etwa so www.dsdt.info/tutori.../tobjectlist/?page=2

Ja, etwa so. ;)

user profile iconUnknown hat folgendes geschrieben:
Edit3:Das mit ObjectList funzt bei mir net

Du musst noch die Unit hinzufügen:
ausblenden Delphi-Quelltext
1:
2:
uses
  ..., Contnrs;


user profile iconUnknown hat folgendes geschrieben:
da ich nicht weiß, wie man ein Image erstellt mit den gleichen "Sachen" wie ein anderes

Ansatz: Image-Kompo erzeugen und dann per Assign() von der schon vorhandenen das Bild/Eigenschaften kopieren. :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Unknown Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 184

Win XP
Delphi 7
BeitragVerfasst: Mo 25.06.07 15:35 
Ich hab doch im Timer Image1.blablabla gecshrieben....
Soll ich dann Image.assign(Timer1) schreiben ??
Aber das mit Objectlist versuch ich jetzt ma......
Da hab ich noch ne Frage zu Objectlist, und zwar:
-Wie kann ich schreiben, das die Objecte immer nach links gehen bis die an der Grenze sind ????
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 25.06.07 15:53 
Moin!

OMG... :roll: ;)

user profile iconUnknown hat folgendes geschrieben:
Ich hab doch im Timer Image1.blablabla gecshrieben....

Das glaube ich kaum... 8)

user profile iconUnknown hat folgendes geschrieben:
Soll ich dann Image.assign(Timer1) schreiben ??

Du willst dem Image doch keinen Timer zuweisen, oder? :| Sondern: du willst im Timer-Ereignis neue Images anlegen :arrow: da muss also irgendwie sowas auftauchen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
  var
    Image: TImage;
begin
  Image := TImage.Create(NIL);
  Image.Parent := Form1; // oder was auch immer
  Image.Picture.Bitmap.Assign(ImageVorlage); // Bild kopieren
  Image.Top := ... usw.
  ObjectList1.Add(Image); // in die Liste


user profile iconUnknown hat folgendes geschrieben:
Wie kann ich schreiben, das die Objecte immer nach links gehen bis die an der Grenze sind?

Ansatz: du läufst durch die Objekte in der Liste und bearbeitest ihre Eigenschaften entsprechend:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
  var
    i: Integer;
    Image: TImage;
begin
  for i := 0 to ObjectList1.Count-1 do begin
    Image := TImage(ObjectList1.Items[i]); // Zugriff auf das Image
    Image.Left := Image.Left -1// nach links schieben

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.