JanV
10th September 2008 16:56 UTC
NSD_CreateText and line breaks
I've traded in the use of ini pages for nsDialogs. But I have a problem with filling a text box and filling it with lines of text that are separated by carrige return/line feeds.
A code snipped to demonstrate what I doing:
!include nsDialogs.nsh
Name Test
OutFile Test.exe
Page custom nsDialogsPage
;Page instfiles
Function nsDialogsPage
Push $0
Push $1
nsDialogs::Create /NOUNLOAD 1018
Pop $0
${NSD_CreateText} 0 13u 100% -13u ""
Pop $0
StrCpy $1 "Line 1 \r\nLine 2"
SendMessage $0 ${WM_SETTEXT} 0 "STR:$1"
nsDialogs::Show
Pop $1
Pop $0
FunctionEnd
Section
DetailPrint "Hello world"
SectionEnd
So what I want is to display 'Line 1' and (on the following line) 'Line 2' in the 'text box' created by NSD_CreateText.
But alas, the '\r\n' is not converted to a line feed but it is displayed as plain text.
Does anyone know how to solve this?
{_trueparuex^}
10th September 2008 20:25 UTC
Use $\r$\n instead. ;)
PaR
JanV
11th September 2008 12:52 UTC
"Use $\r$\n instead"
I'm sorry, I should have mentioned it in the first post, but I did already try that. The effect of this is that '$\r$\n' shows up in the form as two tiny rectangles. So the problem still remains...
Anders
11th September 2008 13:03 UTC
you want a multiline textbox, if nsDialogs does not already have one, you can add it in, it would need the ES_MULTILINE style
JanV
11th September 2008 14:34 UTC
Thanks Anders, this set me on the right track. A little searching (Thread 283466 - reply from Pospec) showed me how to do it.
The following code is how I implemented this:
!include nsDialogs.nsh
Name Test
OutFile Test.exe
Page custom nsDialogsPage
;Page instfiles
Function nsDialogsPage
Push $0
Push $1
nsDialogs::Create /NOUNLOAD 1018
Pop $0
nsDialogs::CreateControl /NOUNLOAD ${__NSD_Text_CLASS} ${DEFAULT_STYLES}|\
${WS_TABSTOP}|${ES_AUTOHSCROLL}|${ES_MULTILINE}|${WS_VSCROLL} ${__NSD_Text_EXSTYLE} \
0 13u 100% -13u
Pop $0
StrCpy $1 "Line 1 $\r$\nLine 2"
; StrCpy $1 "Line 1 \r\nLine 2"
SendMessage $0 ${WM_SETTEXT} 0 "STR:$1"
nsDialogs::Show
Pop $1
Pop $0
FunctionEnd
Section
DetailPrint "Hello world"
SectionEnd
This is the solution, thank you for your help Anders!
Jan