If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Tapsa
Earned some good credits
Posts: 147 Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki
Post
by Tapsa » Sat Jan 23, 2016 4:18 pm
I have constructed wxTextCtrls using:
Code: Select all
wxTextCtrl(parent, wxID_ANY, "", wxDefaultPosition, dimensions, wxTE_MULTILINE)
\n in the strings is neither converted to actual new line nor displayed in any way. It is completely omitted in the wxTextCtrl. How can I make it appear as \n or as new line?
I'm using 2.8.12.
DenDev
Filthy Rich wx Solver
Posts: 231 Joined: Mon Jan 19, 2015 1:45 pm
Post
by DenDev » Sat Jan 23, 2016 4:23 pm
It works in wx version 3.0.2. You might try to "\r\n" instead since that is the default line break sequence in windows.
I have a bad habbit of not testing the code I post
Tapsa
Earned some good credits
Posts: 147 Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki
Post
by Tapsa » Sat Jan 23, 2016 4:49 pm
They are strings loaded from DLL. I would rather have them shown as they are.
Block\nPrinting
doublemax
Moderator
Posts: 19160 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Sat Jan 23, 2016 4:56 pm
What exactly does the string contain, the real newline code (0x0a) or the characters "\" and "n"?
Use the source, Luke!
Tapsa
Earned some good credits
Posts: 147 Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki
Post
by Tapsa » Sat Jan 23, 2016 5:00 pm
Using hex viewer I can see "42 00 6C 00 6F 00 63 00 6B 00 0A 00 50 00 72 00 69 00 6E 00 74 00 69 00 6E 00 67 00" so yes it has 0A aka new line.
doublemax
Moderator
Posts: 19160 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Sat Jan 23, 2016 5:09 pm
That makes sense, because i don't think the text control itself converts "\n" to 0x0a.
If you want to display 0x0a as "\n", you'll have to replace it in the string. I don't think you can tell the text control to display it differently.
Use the source, Luke!
DenDev
Filthy Rich wx Solver
Posts: 231 Joined: Mon Jan 19, 2015 1:45 pm
Post
by DenDev » Sat Jan 23, 2016 6:21 pm
Does a replace do any change?
Code: Select all
wxString str = (set to whatever);
str.Replace("\n", "\r\n");
text_ctrl->AppendText(str);
I have a bad habbit of not testing the code I post
Tapsa
Earned some good credits
Posts: 147 Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki
Post
by Tapsa » Sat Jan 23, 2016 6:48 pm
Thank you. I had lots to do so took a while before testing this.
Apparently Resource Hacker and Resource Tuner both replace 0x0A with \n.
DenDev
Filthy Rich wx Solver
Posts: 231 Joined: Mon Jan 19, 2015 1:45 pm
Post
by DenDev » Sat Jan 23, 2016 7:48 pm
\n is just a C-style escape character for 0x0A and equals to \x0a, \r\n equals to \x13\x0a
I have a bad habbit of not testing the code I post