unit TexPanel;
interface
uses
SysUtils, Classes, Controls, ExtCtrls, graphics, types, Messages, Windows,
MultiMon, Menus, CommCtrl, Imm, ImgList, ActnList;
type
TTexPanel = class(TPanel)
private
{ Private-Deklarationen }
FImage: TImage;
FPicture: TPicture;
procedure SetPicture(const Value: TPicture);
procedure CreateWnd; override;
protected
{ Protected-Deklarationen }
procedure Resize; override;
public
{ Public-Deklarationen }
constructor Create(aOwner: TComponent); override;
destructor Destroy; override;
published
{ Published-Deklarationen }
property Picture: TPicture read FPicture write SetPicture;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TTexPanel]);
end;
{ TImagepanel }
constructor TTexPanel.Create(aOwner: TComponent);
begin
inherited Create (aOwner);
FPicture := TPicture.Create;
FImage := TImage.Create(self);
with FImage do
begin
Parent := self;
Align := alLeft;
end;
bevelinner := bvNone;
bevelouter := bvNone;
end;
procedure TTexPanel.CreateWnd;
begin
inherited CreateWnd;
SetPicture(fPicture);
end;
destructor TTexPanel.Destroy;
begin
FreeAndNil(FPicture);
FreeAndNil(FImage);
inherited Destroy;
end;
procedure TTexPanel.Resize;
begin
fImage.Picture.Bitmap.Width := width;
fImage.Picture.Bitmap.Height := height;
inherited;
end;
procedure TTexPanel.SetPicture(const Value: TPicture);
begin
FPicture.Assign(Value);
fImage.Picture := nil;
FImage.Canvas.Brush.Bitmap := fPicture.Bitmap;
fImage.Canvas.FillRect(Rect(0,0,fImage.Width, fImage.Height));
Paint;
end;