Quote
In article <38195a92.4526...@forums.inprise.com>, Paul Linehan wrote:
> Out of sheer curiousity I tried this.
> It works for a Label but not for a Button.
A button needs to be created with the BS_MULTILINE style to be able to
show multiple lines. This is easy to do, see below. The component
allows you to insert linebreaks in the designer by inserting a |
character.
unit MLButton;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
StdCtrls;
type
TMultilineButton = class(Tbutton)
private
FMultiline: Boolean;
function GetCaption: String;
procedure SetCaption(const Value: String);
procedure SetMultiline(const Value: Boolean);
public
Procedure CreateParams( Var params: TCreateParams ); override;
Constructor Create( aOwner: TComponent ); override;
published
property Multiline: Boolean read FMultiline write SetMultiline
default True;
property Caption: String read GetCaption write SetCaption;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('PBGoodies', [TMultilineButton]);
end;
{ TMultilineButton }
constructor TMultilineButton.Create(aOwner: TComponent);
begin
inherited;
FMultiline := True;
end;
procedure TMultilineButton.CreateParams(var params: TCreateParams);
begin
inherited;
If FMultiline Then
params.Style := params.Style or BS_MULTILINE;
end;
function TMultilineButton.GetCaption: String;
begin
Result := Stringreplace( inherited Caption, #13, '|', [rfReplaceAll]
);
end;
procedure TMultilineButton.SetCaption(const Value: String);
begin
If value <> Caption Then Begin
inherited Caption := Stringreplace( value, '|', #13, [rfReplaceAll]
);
Invalidate;
End;
end;
procedure TMultilineButton.SetMultiline(const Value: Boolean);
begin
If FMultiline <> Value Then Begin
FMultiline := Value;
RecreateWnd;
End;
end;
end.
Peter Below (TeamB) 100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!