Recent

Author Topic: Multiline button caption - can't figure out how to do  (Read 22549 times)

Paul-SFL

  • New Member
  • *
  • Posts: 22
Multiline button caption - can't figure out how to do
« on: September 17, 2011, 11:20:11 pm »
Hello,

I'm completely new to Delphi and Lazarus (I only studied Turbo Pascal), so I ask for help here.

I cannot understand how to make button caption multiline; Google haven't helped and manuals too. Can anyone please tell me what should I do or where can I find examples?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Multiline button caption - can't figure out how to do
« Reply #1 on: September 17, 2011, 11:32:48 pm »
Use a TSpeedButton with an image.

You can do also:

Code: [Select]
SpeedButton1.Caption := 'a' +#13#10 + 'b'; 
« Last Edit: September 17, 2011, 11:37:43 pm by typo »

Paul-SFL

  • New Member
  • *
  • Posts: 22
Re: Multiline button caption - can't figure out how to do
« Reply #2 on: September 17, 2011, 11:50:07 pm »
Thanks, I'll try it.
As for code you wrote, where should I insert it? Into some procedure related to form creation?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Multiline button caption - can't figure out how to do
« Reply #3 on: September 17, 2011, 11:52:11 pm »
Yes.

Paul-SFL

  • New Member
  • *
  • Posts: 22
Re: Multiline button caption - can't figure out how to do
« Reply #4 on: September 18, 2011, 12:10:53 am »
Ok, that's all for the moment. Going to try your advice tomorrow.

Paul-SFL

  • New Member
  • *
  • Posts: 22
Re: Multiline button caption - can't figure out how to do
« Reply #5 on: September 18, 2011, 06:44:51 pm »
Thank you typo, the code works :) .

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Multiline button caption - can't figure out how to do
« Reply #6 on: September 18, 2011, 08:48:14 pm »
don't use #13#10, use the constant LineEnding instead

Paul-SFL

  • New Member
  • *
  • Posts: 22
Re: Multiline button caption - can't figure out how to do
« Reply #7 on: September 18, 2011, 09:43:45 pm »
Thanks for the advice, but I can see no essential difference :) . Am I mistaken?

mdalacu

  • Full Member
  • ***
  • Posts: 234
    • dmSimpleApps
Re: Multiline button caption - can't figure out how to do
« Reply #8 on: September 18, 2011, 09:54:15 pm »
Windows / Linux difference . No CR on Linux.

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Re: Multiline button caption - can't figure out how to do
« Reply #9 on: September 19, 2011, 01:53:51 am »
This works in windows.  I have not tried it with *nix.

Code: [Select]
  SpeedButton1.Caption := 'Row1' + sLineBreak + 'Row2';

Bandbaz

  • New Member
  • *
  • Posts: 40
Re: Multiline button caption - can't figure out how to do
« Reply #10 on: September 19, 2011, 08:35:28 am »
Code: [Select]
SpeedButton1.Caption := 'Row1' + sLineBreak + 'Row2';
SpeedButton2.Caption := 'Row1' + LineEnding + 'Row2';
SpeedButton3.Caption := 'Row1' + #13#10 + 'Row2';

none of them works for me

lazarus 0.9.30 gtk2 ubuntu 11.4
« Last Edit: September 19, 2011, 08:41:55 am by Bandbaz »

Bandbaz

  • New Member
  • *
  • Posts: 40
Re: Multiline button caption - can't figure out how to do
« Reply #11 on: September 19, 2011, 11:33:40 am »
I tried again on TButton and TBitBtn
all 3 codes working good!

so, maybe you should not use SpeedButton if you don't have image on it.


lazarus 0.9.30 gtk2 ubuntu 11.4

Zoran

  • Hero Member
  • *****
  • Posts: 1980
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Multiline button caption - can't figure out how to do
« Reply #12 on: September 19, 2011, 12:51:31 pm »
Thanks for the advice, but I can see no essential difference :) . Am I mistaken?

LineEnding is mapped to #13#10 in Windows, #10 in Linux and #13 in Mac. If you want your code to be cross platform, do not use hard-coded values, but always use cross-platform constants instead.

See: http://wiki.lazarus.freepascal.org/End_of_Line
See also: http://wiki.lazarus.freepascal.org/Multiplatform_Programming_Guide#Working_with_files_and_folders
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Multiline button caption - can't figure out how to do
« Reply #13 on: September 19, 2011, 01:45:59 pm »
Code: [Select]
....  .Caption := 'Row1' + LineEnding + 'Row2';For me works for all three, TButton, TBitBtn and TSpeedButton (Linux+Qt).
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Paul-SFL

  • New Member
  • *
  • Posts: 22
Re: Multiline button caption - can't figure out how to do
« Reply #14 on: September 19, 2011, 06:52:24 pm »
Thank you all for the explanation guys :) . Though I'm writing a Windows program, I'm going to follow your advice.

 

TinyPortal © 2005-2018