to 碧血剑
我设了, 但是不行
我贴出员码
unit u_treelist;
interface
uses
{$IFDEF WIN32}Windows,{$ELSE}Winprocs,{$ENDIF}
Messages, SysUtils, Classes, Graphics, Controls, Forms,
StdCtrls,ComCtrls,ExtCtrls,Buttons;
type
tlisttree = class(TCustomEdit)
private
Fbutton:tspeedbutton;
ftreeview:ttreeview;
procedure SetbuttonPosition;
protected
procedure createwnd; override;
procedure SetParent(AParent: TWinControl); override;
procedure Notification(AComponent: TComponent;
Operation: TOperation);override;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure SetBounds(ALeft: Integer; ATop: Integer; AWidth: Integer; AHeight: Integer); override;
procedure addbutton;
end;
procedure Register;
implementation
{tlisttree}
constructor tlisttree.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
addbutton;
end;
destructor tlisttree.Destroy;
begin
inherited destroy;
end;
procedure tlisttree.createwnd;
begin
inherited createwnd;
with fbutton do begin
caption:='▼';
// visible:=false
end;
end;
procedure tlisttree.addbutton ;
begin
Fbutton:=tspeedbutton.Create(self);
Fbutton.FreeNotification(Self);
ftreeview:=ttreeview.Create(self);
ftreeview.FreeNotification(self);
end;
procedure tlisttree.SetParent(AParent: TWinControl);
begin
inherited setparent(aparent);
if fbutton<>nil then begin
fbutton.Parent :=aparent;
fbutton.Visible :=true;
end;
if ftreeview<>nil then begin
ftreeview.Parent :=aparent;
ftreeview.Visible :=false;
end;
end;
procedure Tlisttree.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (AComponent = Fbutton) and (Operation = opRemove) then
Fbutton := nil;
if (AComponent = Ftreeview) and (Operation = opRemove) then
Ftreeview := nil;
end;
procedure tlisttree.SetbuttonPosition ;
var
P: TPoint;
begin
if fbutton<>nil then
Fbutton.SetBounds(left+width,top,fbutton.Width,height);
if ftreeview<>nil then
Ftreeview.SetBounds(left,top+height,Width,20);
end;
procedure tlisttree.SetBounds;
begin
inherited SetBounds(ALeft, ATop, AWidth, AHeight);
SetbuttonPosition;
end;
(************************************)
{***************************************************************************}
procedure Register;
begin
RegisterComponents('myvcl', [tlisttree]);
end;
end.