Board index » delphi » Word wrap TButton Caption

Word wrap TButton Caption

How can I make a TButton's Caption word wrap so a long caption can be on
several lines on a somewhat taller button, rather than using a very wide
button?

Thanks,
Jon

 

Re:Word wrap TButton Caption


On Mon, 1 Apr 2002 10:37:58 -0600, "Jon Jacobs" <jqjac...@gte.net>
wrote:

Quote
>How can I make a TButton's Caption word wrap so a long caption can be on
>several lines on a somewhat taller button, rather than using a very wide
>button?

In form's constructor

Btn.Caption:= 'This is multiline'#13#10'caption';

HTH
ain

Re:Word wrap TButton Caption


View the Form as Text (Alt+F12).

          object btnEligInq: TSpeedButton
            Left = 419
            Top = 98
            Width = 86
            Height = 53
            Caption = 'Eligibility'#13'Inquiry'

Regards,
-Steve-

Re:Word wrap TButton Caption


Thanks, I tried it, but it didn't work. D5 & D6.

Jon

Quote
"Steve Zimmelman" <sk_z@psi_med.com> wrote in message

news:3ca8c09e$1_1@dnews...
Quote
> View the Form as Text (Alt+F12).

>           object btnEligInq: TSpeedButton
>             Left = 419
>             Top = 98
>             Width = 86
>             Height = 53
>             Caption = 'Eligibility'#13'Inquiry'

> Regards,
> -Steve-

Re:Word wrap TButton Caption


Thanks, but that was the first thing I tried, and it didn't work, so I asked
here.
D5 & D6

Jon

Quote
<Ain Valtin> wrote in message

news:3ca8930c.194695387@newsgroups.borland.com...
Quote
> On Mon, 1 Apr 2002 10:37:58 -0600, "Jon Jacobs" <jqjac...@gte.net>
> wrote:

> >How can I make a TButton's Caption word wrap so a long caption can be on
> >several lines on a somewhat taller button, rather than using a very wide
> >button?

> In form's constructor

> Btn.Caption:= 'This is multiline'#13#10'caption';

> HTH
> ain

Re:Word wrap TButton Caption


Hi Jon

You can make your own button with that simple code :

TMyButton = class(TButton)
protected
  procedure CreateParams(var Params: TCreateParams); override;
end;
...
procedure TMyButton.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.Style := Params.Style or BS_MULTILINE;
end;

\Francois

Quote
Jon Jacobs wrote:
> Thanks, I tried it, but it didn't work. D5 & D6.

> Jon

> "Steve Zimmelman" <sk_z@psi_med.com> wrote in message
> news:3ca8c09e$1_1@dnews...
> > View the Form as Text (Alt+F12).

> >           object btnEligInq: TSpeedButton
> >             Left = 419
> >             Top = 98
> >             Width = 86
> >             Height = 53
> >             Caption = 'Eligibility'#13'Inquiry'

> > Regards,
> > -Steve-

Re:Word wrap TButton Caption


I was hoping to work with the existing TButton, but at this point, it looks
like the only way is to derive a descendant just as you showed. Thank you
very much.

Jon

Quote
"Francois Labonte" <labon...@videotron.ca> wrote in message

news:3CACA2E2.A401D5D9@videotron.ca...
Quote
> Hi Jon

> You can make your own button with that simple code :

> TMyButton = class(TButton)
> protected
>   procedure CreateParams(var Params: TCreateParams); override;
> end;
> ...
> procedure TMyButton.CreateParams(var Params: TCreateParams);
> begin
> inherited;
> Params.Style := Params.Style or BS_MULTILINE;
> end;

> \Francois

> Jon Jacobs wrote:

> > Thanks, I tried it, but it didn't work. D5 & D6.

> > Jon

> > "Steve Zimmelman" <sk_z@psi_med.com> wrote in message
> > news:3ca8c09e$1_1@dnews...
> > > View the Form as Text (Alt+F12).

> > >           object btnEligInq: TSpeedButton
> > >             Left = 419
> > >             Top = 98
> > >             Width = 86
> > >             Height = 53
> > >             Caption = 'Eligibility'#13'Inquiry'

> > > Regards,
> > > -Steve-

Re:Word wrap TButton Caption


Funny, I've got that exact code in 2 D5 apps.  In fact, the code snippet I posted
came from one of my apps.

Regards,
-Steve-

Quote
"Jon Jacobs" <jqjac...@gte.net> wrote in message news:3cac8e75_2@dnews...

Thanks, I tried it, but it didn't work. D5 & D6.

Jon

Re:Word wrap TButton Caption


Quote
In article <3cacd291_1@dnews>, Steve Zimmelman wrote:
> Funny, I've got that exact code in 2 D5 apps.  In fact, the code snippet I posted
> came from one of my apps.

I think it works with TBitBtns, which are ownerdrawn buttons, but for TButtons you
have to add the BS_MULTILINE style to the button to make it work.
--
Peter Below (TeamB)  
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Re:Word wrap TButton Caption


I'll try that with TBitBtn's.
Thanks,
Jon

"Peter Below (TeamB)" <100113.1...@compuXXserve.com> wrote in message
news:VA.0000876f.01486f2e@antispam.compuserve.com...

Quote
> In article <3cacd291_1@dnews>, Steve Zimmelman wrote:
> > Funny, I've got that exact code in 2 D5 apps.  In fact, the code snippet
I posted
> > came from one of my apps.

> I think it works with TBitBtns, which are ownerdrawn buttons, but for
TButtons you
> have to add the BS_MULTILINE style to the button to make it work.
> --
> Peter Below (TeamB)
> Use the newsgroup archives :
> http://www.mers.com/searchsite.html
> http://www.tamaracka.com/search.htm
> http://groups.google.com
> http://www.prolix.be

Re:Word wrap TButton Caption


Yes! It works with TBitBtn!
--
Jon
http://home1.gte.net/jqjacobs/index.htm
This posting was made entirely from recycled electrons. No innocent atoms
were harmed.
Quote
> I think it works with TBitBtns, which are ownerdrawn buttons, but for
TButtons you
> have to add the BS_MULTILINE style to the button to make it work.

Re:Word wrap TButton Caption


"Jon Jacobs" wrote

Quote
> How can I make a TButton's Caption word wrap so a long caption can be on
> several lines on a somewhat taller button, rather than using a very wide
> button?

You can't easily do it with TButton component, even if you set its caption
to somewhat containing #13#10.
If your application allows, you TBitBtn instead and follow the answers given
before, if not, try to descend a new component from TButton and override its
CreateParams method where say:

procedure TMyButton.CreateParams(var params: TCreateParams);
begin
  inherited;
  params.Style := params.Style or BS_MULTILINE;
end;

The excellent example of standard button with multiline caption is Peter
Below's TMLButton in jvGoodies archieve at www.delphi-jedi.org

Hope this helps,
Igor Schevchenko

Other Threads