unit mytestbtn;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, ExtCtrls, Dialogs, Buttons,
lclintf;
type
TMytestbtn = class(TCustomControl)
private
FGlyph: TBitmap;
fbtnEXTRA : TBitBtn;
procedure GlyphChanged(Sender: TObject);
function IsGlyphStored: Boolean;
procedure SetGlyph(AValue: TBitmap);
protected
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Glyph: TBitmap read FGlyph write SetGlyph stored IsGlyphStored;
end;
procedure Register;
implementation
constructor TMytestbtn.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
FGlyph := TBitmap.Create;
FGlyph.OnChange := @GlyphChanged;
Color := clLime;
fbtnEXTRA := TBitBtn.Create(self);
With fbtnEXTRA do
begin
Top := 10;
Left := 10;
Width := 80;
Height := 80;
Caption := '';
Layout := blGlyphTop;
Parent := Self;
end;
SetInitialBounds(0, 0, 100, 100);
end;
Destructor TMytestbtn.Destroy;
begin
FGlyph.Free;
inherited Destroy;
end;
procedure TMytestbtn.GlyphChanged(Sender: TObject);
begin
Invalidate;
end;
function TMytestbtn.IsGlyphStored: Boolean;
begin
Result := not FGlyph.Empty;
end;
procedure TMytestbtn.Paint;
begin
inherited Paint;
fbtnEXTRA.Glyph.Assign(FGlyph);
end;
procedure TMytestbtn.SetGlyph(AValue: TBitmap);
begin
FGlyph.Assign(AValue);
end;
procedure Register;
begin
RegisterComponents('Misc', [TMytestbtn]);
end;
end.