Home » Community » Newbie corner » "\n" does not work on DrawText
"\n" does not work on DrawText [message #46089] |
Thu, 03 March 2016 08:33  |
Giorgio
Messages: 218 Registered: August 2015
|
Experienced Member |
|
|
Hi there,
following my post DrawText and carriage return, I decided to insert the carriage return using some lines of code. The code is really simple but should do the trick. I basically add a "\n" after 35 chars, but it seems something is going wrong. The code add a char in the WString (I notice an extra space in the phrase), but it actually does not make a carriage return: the WString is still on a line. What is the escape sequence to be used with DrawText to have a carriage return?
Regards,
Gio
|
|
|
Re: "\n" does not work on DrawText [message #46091 is a reply to message #46089] |
Thu, 03 March 2016 11:11   |
omari
Messages: 276 Registered: March 2010
|
Experienced Member |
|
|
Hello,
DrawTexe does not interprete \n, you have to split the string, and to call DrawTexe repeatedly to display each line.
for example:
void DrawAsLines(Draw& w, int x, int y, WString s)
{
int n = 0;
int dh = 14;
int line_size = 13;
while (n + line_size < s.GetCount())
{
String next = s.Mid(n, line_size);
n += line_size;
w.DrawTexe(x, y, next);
y += dh;
}
String next = s.Mid(n);
w.DrawTexe(x, y, next);
}
regards
omari.
|
|
|
|
Goto Forum:
Current Time: Sat May 03 17:58:06 CEST 2025
Total time taken to generate the page: 0.00935 seconds
|