unit TextButton;

interface

uses
  Windows, Classes, Controls, StdCtrls;

type
  TTextButton = class(TButton)
  private
    { Private declarations }
    FAlignment: TAlignment;
    FWordWrap: Boolean;
    FLayout: TTextLayout;
    procedure SetAlignment(Value: TAlignment);
    procedure SetWordWrap(Value: Boolean);
    procedure SetLayout(Value: TTextLayout);
  protected
    procedure CreateParams(var Params: TCreateParams); override;
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
  published
    { Published declarations }
    property Alignment: TAlignment read FAlignment write SetAlignment default taCenter;
    property WordWrap: Boolean read FWordWrap write SetWordWrap default False;
    property Layout: TTextLayout read FLayout write SetLayout default tlCenter;
  end;

procedure Register;

implementation

constructor TTextButton.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FAlignment := taCenter;
  FWordWrap := False;
  FLayout := tlCenter;
end;

procedure TTextButton.CreateParams(var Params: TCreateParams);
const
  Alignments: array[TAlignment] of Word = (BS_LEFT, BS_RIGHT, 0);
  WordWraps: array[Boolean] of Word = (0, BS_MULTILINE);
  TextLayouts: array[TTextLayout] of Word = (BS_TOP, 0, BS_BOTTOM);
begin
  inherited CreateParams(Params);
  Params.Style := Params.Style or Alignments[FAlignment]
                               or WordWraps[FWordWrap]
                               or TextLayouts[FLayout];
end;

procedure TTextButton.SetAlignment(Value: TAlignment);
begin
  FAlignment := Value;
  RecreateWnd;
end;

procedure TTextButton.SetWordWrap(Value: Boolean);
begin
  FWordWrap := Value;
  RecreateWnd;
end;

procedure TTextButton.SetLayout(Value: TTextLayout);
begin
  FLayout := Value;
  RecreateWnd;
end;

procedure Register;
begin
  RegisterComponents('Samples', [TTextButton]);
end;

end.
