Jump to content
Devis

Making text go onto 2 lines?

Recommended Posts

Hi there, Ive been reading alot of tutorials on TForms, and im creating a button for a TForm. But I want the caption on the button to be spread over 2 lines, instead of one long line of text.

 

At the moment my Text is:

 

CloseBut.Caption :='Shut Down Program.';

 

But I saw on a tutorial something like:

 

CloseBut.Caption :='Shut Down' + #10#13 + 'Program.';

 

To make the Shut Down and Program on seperate lines.. but cant get it to work.. just wondered what the right code is and what the "#10#13" means?

 

Thanks :)

Link to comment
Share on other sites

Hi there, Ive been reading alot of tutorials on TForms, and im creating a button for a TForm. But I want the caption on the button to be spread over 2 lines, instead of one long line of text.

 

At the moment my Text is:

 

CloseBut.Caption :='Shut Down Program.';

 

But I saw on a tutorial something like:

 

CloseBut.Caption :='Shut Down' + #10#13 + 'Program.';

 

To make the Shut Down and Program on seperate lines.. but cant get it to work.. just wondered what the right code is and what the "#10#13" means?

 

Thanks :)

 

Just tested it. For TButton's. There is a WordWrap property. Once you set that, if the caption exceeds the width of the button it will go to the next line. No '/n' new line special character needed. Always check for Multiline and WordWrap properties.

 

[sCAR]

var

a: TButton;

begin

a.WordWrap := True;

end.

[/sCAR]

 

#10#13, is the special code for new line in delphi or w/e. If you know C language (/n) or text encoding it is the equivalent of a NEW LINE, or Carriage return I think in ASCII or some other encoding format.

Edited by LordJashin
Link to comment
Share on other sites

Thanks :) Works perfectly, and thanks for the explanation on the #10#13 code. IS some delphi code implemented into SCAR? Ive noticed on some tutorials they refer to delphi code. Im a nooby a coding so dont really know much about it hehe

Link to comment
Share on other sites

Thanks :) Works perfectly, and thanks for the explanation on the #10#13 code. IS some delphi code implemented into SCAR? Ive noticed on some tutorials they refer to delphi code. Im a nooby a coding so dont really know much about it hehe

 

SCAR is written in Delphi which is a form of Object Pascal, SCAR's script engine also offers an Object Pascal based language, the result is that most principles are exactly the same as they are in Delphi.

Link to comment
Share on other sites

Just for reference incase anyone wants to know.

 

+Chr(10)+

 

Is the code used to make text go onto a second line manualy without using the TextWrap feature.

 

 

For example:

[scar]program New;

begin

Writeln('Hello' +Chr(10)+ 'World!');

end.[/scar]

 

Outputs:

Successfully compiled

Hello

World!

Successfully executed

 

Useful for usage in button captions, Forms, and messages such as ShowMessage(); when you want to manualy decide what text is on each line.

 

B|

Link to comment
Share on other sites

It's actually #13#10 or Chr(13) + Chr(10) in Windows, #10 is the newline character which is the default for Unix, Windows prepends the #13 return character, but the debugbox accept either format. However, take in mind that when writing files which other apps are required to open, you should use #13#10.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...