Also hier ist mal der Code:
Delphi-Quellcode:
unit ImagePanel;
interface
uses
SysUtils, Classes, Controls, ExtCtrls, Graphics, Dialogs,
StdCtrls;
type
TImagePanel =
class(TPanel)
private
{ Private-Deklarationen }
FImage: TImage;
FPicture: TPicture;
procedure SetPicture(
const Value: TPicture);
protected
{ Protected-Deklarationen }
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('
Test', [TImagepanel]);
end;
{ TImagepanel }
constructor TImagepanel.Create(aOwner: TComponent);
begin
inherited Create (aOwner);
FPicture := TPicture.Create;
FImage := TImage.Create(self);
with FImage
do
begin
Parent := self;
Align := alClient;
Stretch := True;
end;
end;
destructor TImagePanel.Destroy;
begin
FreeAndNil(FPicture);
FreeAndNil(FImage);
inherited Destroy;
end;
procedure TImagePanel.SetPicture(
const Value: TPicture);
begin
FPicture.Assign(Value);
FImage.Picture := Value;
// ? Ist diese Zeile nötig ?
Paint;
end;
end.
Was muss ich ändern, damit das Problem verschwindet?