Registriert seit: 31. Jan 2008
12 Beiträge
|
AW: eigene Klasse; Constructor inkl. TImage
23. Jun 2010, 00:42
Habs gelöst !!
Klasse:
Delphi-Quellcode:
unit enemy;
interface
uses ExtCtrls,Classes,Forms,Windows;
Type TEnemy = class(TComponent)
private
enemyimage : TImage;
enemyname : string;
public
enemypath : string;
enemysize : integer;
enemypriority : double;
constructor Create(AParent: TForm; EName: string; IHandle : HICON);
end;
TEnemyArray = array of TEnemy;
implementation
Constructor TEnemy.Create(AParent: TForm; EName: string; IHandle : HICON);
begin
enemyimage := TImage.Create(AParent);
with enemyimage do
begin
Parent := AParent;
Left := 400;
Top := 400;
AutoSize := true;
Picture.Icon.Handle := IHANDLE;
enemyname := EName;
end;
end;
end.
Procedure:
Delphi-Quellcode:
procedure tfrm_main.init_enemyarray();
VAR I : integer ;
begin
SetLength(EnemyArray,FileListBox1.Count+1);
try
for I := 0 to FileListBox1.Count-1 do
begin
EnemyArray[I] := TEnemy.Create(frm_main,FileListBox1.Items.Strings[I],GetShellIcon(FileListBox1.Directory+' \'+FileListBox1.Items.Strings[I], True, False));
end;
except
on E : Exception do
begin
WriteLog(E. Message + ' : ' + IntToStr(I));
ShowMessage(E. Message + ' : ' + IntToStr(I));
end;
end;
end;
Gruß
Daniel
|
|
Zitat
|