C
china_ren
Unregistered / Unconfirmed
GUEST, unregistred user!
unit TreeView1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls,extdlgs,Consts;
type
TTreeView1 = class(TTreeView)
private
image:TPicture;
procedure setimage(value:TPicture);
function getcanvas:Tcanvas;
public
constructor create(aowner:tcomponent);override;
destructor destroy;override;
property Canvas:TCanvas read getcanvas;
published
property Picture:TPicture read image write setimage;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TTreeView1]);
end;
function TTreeView1.GetCanvas: TCanvas;
var
Bitmap: TBitmap;
begin
if image.Graphic = nil then
begin
Bitmap := TBitmap.Create;
try
Bitmap.Width := Width;
Bitmap.Height := Height;
image.Graphic := Bitmap;
finally
Bitmap.Free;
end;
end;
if image.Graphic is TBitmap then
Result := TBitmap(image.Graphic).Canvas;
end;
procedure TTreeView1.setimage(value:TPicture);
begin
ControlStyle := ControlStyle + [csReplicatable];
image.Assign(value);
end;
constructor TTreeView1.create(aowner:tcomponent);
begin
inherited create(aowner);
image:=TPicture.Create;
end;
destructor TTreeView1.destroy;
begin
image.Free;
inherited destroy;
end;
end.
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls,extdlgs,Consts;
type
TTreeView1 = class(TTreeView)
private
image:TPicture;
procedure setimage(value:TPicture);
function getcanvas:Tcanvas;
public
constructor create(aowner:tcomponent);override;
destructor destroy;override;
property Canvas:TCanvas read getcanvas;
published
property Picture:TPicture read image write setimage;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TTreeView1]);
end;
function TTreeView1.GetCanvas: TCanvas;
var
Bitmap: TBitmap;
begin
if image.Graphic = nil then
begin
Bitmap := TBitmap.Create;
try
Bitmap.Width := Width;
Bitmap.Height := Height;
image.Graphic := Bitmap;
finally
Bitmap.Free;
end;
end;
if image.Graphic is TBitmap then
Result := TBitmap(image.Graphic).Canvas;
end;
procedure TTreeView1.setimage(value:TPicture);
begin
ControlStyle := ControlStyle + [csReplicatable];
image.Assign(value);
end;
constructor TTreeView1.create(aowner:tcomponent);
begin
inherited create(aowner);
image:=TPicture.Create;
end;
destructor TTreeView1.destroy;
begin
image.Free;
inherited destroy;
end;
end.