B
biechangjiang
Unregistered / Unconfirmed
GUEST, unregistred user!
我从panel继承下来一个类。里面有 TImage类与TTreeView类。
我能正常的改变属性。可是我怎么样做这两个类的相应的触发事件呀!如点击重画
代码如下:
unit MyPanel;
interface
uses
SysUtils, Classes, Controls, ExtCtrls,ComCtrls;
type
TMyPanel = class(TPanel)
private
FImage : TImage;
FTreeView : TTreeView;
FOnImageClick : TNotifyEvent;
{ Private declarations }
protected
{ Protected declarations }
public
constructor Create( AOwner: TComponent ); override;
destructor Destroy; override;
{ Public declarations }
published
property Image : TImage read FImage;
property TreeView : TTreeView read FTreeView;
property OnImageClick : TNotifyEvent read FOnImageClick write FOnImageClick;
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TMyPanel]);
end;
{ TMyPanel }
constructor TMyPanel.Create(AOwner: TComponent);
begin
inherited;
FImage := TImage.Create(self);
FImage.Align := alTop;
FImage.Show;
FImage.Height := 20;
FImage.Parent := self;
FTreeView := TTreeView.Create(self);
FTreeView.Align := alClient;
FTreeView.Show;
FTreeView.Parent := self;
FImage.OnClick := self.FOnImageClick;
end;
destructor TMyPanel.Destroy;
begin
FImage.Free;
FTreeView.Free;
inherited;
end;
end.
我能正常的改变属性。可是我怎么样做这两个类的相应的触发事件呀!如点击重画
代码如下:
unit MyPanel;
interface
uses
SysUtils, Classes, Controls, ExtCtrls,ComCtrls;
type
TMyPanel = class(TPanel)
private
FImage : TImage;
FTreeView : TTreeView;
FOnImageClick : TNotifyEvent;
{ Private declarations }
protected
{ Protected declarations }
public
constructor Create( AOwner: TComponent ); override;
destructor Destroy; override;
{ Public declarations }
published
property Image : TImage read FImage;
property TreeView : TTreeView read FTreeView;
property OnImageClick : TNotifyEvent read FOnImageClick write FOnImageClick;
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TMyPanel]);
end;
{ TMyPanel }
constructor TMyPanel.Create(AOwner: TComponent);
begin
inherited;
FImage := TImage.Create(self);
FImage.Align := alTop;
FImage.Show;
FImage.Height := 20;
FImage.Parent := self;
FTreeView := TTreeView.Create(self);
FTreeView.Align := alClient;
FTreeView.Show;
FTreeView.Parent := self;
FImage.OnClick := self.FOnImageClick;
end;
destructor TMyPanel.Destroy;
begin
FImage.Free;
FTreeView.Free;
inherited;
end;
end.