unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ImgList;
type
TMyGraphicControl=Class(TGraphicControl)
private
FImageList: TImageList;
FIMageIndex: Integer;
procedure SetImageIndex(
const Value: Integer);
procedure SetImagelist(
const Value: TImageList);
protected
Procedure Paint;
override;
published
Property ImageList:TImageList
read FImageList
Write SetImagelist;
Property ImageIndex:Integer
read FIMageIndex
Write SetImageIndex;
End;
TForm1 =
class(TForm)
ImageList1: TImageList;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
FG:TMyGraphicControl;
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
FG.Left := 100;
FG.Top := 100;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FG := TMyGraphicControl.Create(self);
FG.Parent := self;
FG.Width := ImageList1.Width;
FG.Height := ImageList1.Height;
FG.ImageList := Imagelist1;
FG.ImageIndex := 0;
DoubleBuffered := True;
end;
{ TMyGraphicControl }
procedure TMyGraphicControl.Paint;
begin
if assigned(FImageList)
and (FimageList.Count > FImageIndex)
then
begin
FImageList.Draw(Canvas,0,0,FimageIndex);
end;
end;
procedure TMyGraphicControl.SetImageIndex(
const Value: Integer);
begin
FIMageIndex := Value;
invalidate;
end;
procedure TMyGraphicControl.SetImagelist(
const Value: TImageList);
begin
FImageList := Value;
Invalidate;
end;
end.