J
jsres
Unregistered / Unconfirmed
GUEST, unregistred user!
自己开发了一个复合控件,继承自TPanel,Pannel上面有一个TImage.控件暴露出Picture属性,设计时图片可见,运行时却看不到图片,为什么,请进来看看! ( 积分: 100 )<br />自己开发了一个复合控件,继承自TPanel,Pannel上面有一个TImage.暴露出Picture属性,设计时图片可见,运行时却看不到图片,为什么?
设计时我通过Object Inspector给Picuture选定了一个图片,Panel上的Timage能够显示
但是运行时图片就没了,应该怎么做,标准写法怎么写.请指教
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs, ExtCtrls;
type
TMyPanel = class(TPanel)
private
ImageIcon: TImage;
FPicture: TPicture;
procedure SetPicture(const Value: TPicture);
protected
{ Protected declarations }
public
constructor Create(AOwner: TComponent); override;
published
property Picture: TPicture read FPicture write SetPicture;
end;
procedure Register;
implementation
{$R *.DFM}
procedure Register;
begin
RegisterComponents('Samples', [TMyPanel]);
end;
{ TMyPanel }
constructor TMyPanel.Create(AOwner: TComponent);
begin
inherited;
ImageIcon:=TImage.Create(self);
ImageIcon.Parent:=Self;
ImageIcon.Width:=16;
ImageIcon.Height:16;
end;
procedure TMyPanel.SetPicture(const Value: TPicture);
begin
FPicture.Assign(Value);
ImageIcon.Picture.Assign(FPicture);
end;
end.
设计时我通过Object Inspector给Picuture选定了一个图片,Panel上的Timage能够显示
但是运行时图片就没了,应该怎么做,标准写法怎么写.请指教
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs, ExtCtrls;
type
TMyPanel = class(TPanel)
private
ImageIcon: TImage;
FPicture: TPicture;
procedure SetPicture(const Value: TPicture);
protected
{ Protected declarations }
public
constructor Create(AOwner: TComponent); override;
published
property Picture: TPicture read FPicture write SetPicture;
end;
procedure Register;
implementation
{$R *.DFM}
procedure Register;
begin
RegisterComponents('Samples', [TMyPanel]);
end;
{ TMyPanel }
constructor TMyPanel.Create(AOwner: TComponent);
begin
inherited;
ImageIcon:=TImage.Create(self);
ImageIcon.Parent:=Self;
ImageIcon.Width:=16;
ImageIcon.Height:16;
end;
procedure TMyPanel.SetPicture(const Value: TPicture);
begin
FPicture.Assign(Value);
ImageIcon.Picture.Assign(FPicture);
end;
end.