Archive: Reading a text file into a text box using nsdialog


Reading a text file into a text box using nsdialog
Hello,

I have a textbox on a custom page:

${NSD_CreateText} 160 150 290 50 ''

I have a 24kb text file that I need to load into the text box.

I have use the CustomLicense plug-in before when using InstallOptions:
http://nsis.sourceforge.net/CustomLicense_plug-in

Is there a way to make CustomLicense work with nsDialogs. Or is there another way to get the file loaded in?

Thanks in advance,

Daniel


CustomLicense should work as is with nsDialogs. Just give it the HWND you get from NSD_CreateText.


Hi,

I was able to get it work with this code just in case anyone else needs it:

File /oname=$PLUGINSDIR\EULA.txt "EULA.txt"
${NSD_CreateText} 160 150 290 50
Pop $0
CustomLicense::LoadFile "$PLUGINSDIR\EULA.txt" "$0"

But now I have a new problem with it.

The textbox contains just one really long string of text. It does not show the line breaks that are the file. The file is using CRLF for the line breaks.

When using installoptions this seems to work just fine. But using nsdialgs it has this problem.

Thanks in advance,

Daniel


ok, I figured out. Here it is if anyone needs it:


File /oname=$PLUGINSDIR\EULA.txt "EULA.txt"

nsDialogs::CreateControl /NOUNLOAD ${__NSD_Text_CLASS} ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}|${ES_MULTILINE}|${WS_VSCROLL}|${WS_HSCROLL} ${__NSD_Text_EXSTYLE} 160 150 290 50

POP $0

CustomLicense::LoadFile "$PLUGINSDIR\EULA.txt" "$0"


Thanks for sharing :)


I tried this:

${NSD_CreateText} 160 150 290 50 ""
Pop $0
${NSD_AddStyle} $0 ${ES_MULTILINE}
CustomLicense::LoadFile "$PLUGINSDIR\License.txt" "$0"

It didn't work, the multi line style has no effect. If I append ES_MULTILINE to __NSD_Text_STYLE in nsDialogs.nsh, it works. Why?


Some styles must be there when you create the window or else they have no effect. That's probably one of them.


Oops! What shall I do? (because calling nsDialogs::CreateControl ... doesn't create the textbox, it leaves error on the stack)

I attach my test script.


This is my test:


I got it :)
I forgot last argument - the string after the coordinates.


Where do we insert the text file to print in the text area ???


Add it with the CustomLicense::LoadFile command.
From the various posts above:

nsDialogs::CreateControl /NOUNLOAD ${__NSD_Text_CLASS} ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}|${ES_MULTILINE}|${WS_VSCROLL} ${__NSD_Text_EXSTYLE} 0 0 290 50 ""
Pop $0
CustomLicense::LoadFile "$PLUGINSDIR\License.txt" $0

Thank youvery much for your answer but I add the double quotes and I have steel not text in my TextArea


I am so depress, I spent 5 hours on those lines of NSIS code and I can't find how to print my text in this Textarea :


!define LICENSEPAGE "license.txt"

ReserveFile "${LICENSEPAGE}"

Function textarea
InitPluginsDir

nsDialogs::Create /NOUNLOAD 1018

# 1028 is the id of the branding text control
FindWindow $MUI_TEMP1 "#32770" "" $HWNDPARENT
GetDlgItem $MUI_TEMP1 $HWNDPARENT 1028
SetCtlColors $MUI_TEMP1 0xFFFFFF 0xFFFFFF

FindWindow $1 "#32770" "" $HWNDPARENT
GetDlgItem $1 $1 1000

File /oname=$PLUGINSDIR\${LICENSEPAGE} "${LICENSEPAGE}"

nsDialogs::CreateControl /NOUNLOAD ${__NSD_Text_CLASS} ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}|${ES_MULTILINE}|${WS_VSCROLL}|${WS_HSCROLL} ${__NSD_Text_EXSTYLE} 20 45 425 150 ''
Pop $1
CustomLicense::LoadFile "CGU.txt" $1

nsDialogs::Show
FunctionEnd


Do I forget something anywhere, I installed the plugin to the licensecustom but maybe I forgot something, please Help me ...

Thank you very much


Does the code can be write in a .nsh page and call in the main page .nsi by the command !include "pages\licenseshow.nsh" ??

If I can do it, I surely forgot somthing in my .nsi page, I really don't know want to invent to print this text on my textarea.


Please keep your posts about the same subject in one thread.

Find attached an example Custom License script.

- By placing the License file in the pluginsdir, you make sure that it is deleted when the installer quits, and thus cleaning up the garbage.

- The FindWindow and GetDlgItem is used to find the textbox control, but since we already have the handle to this control, it is not needed.

- The License file should contain the License text you want the user to accept, so you need to write it yourself.
See the several license.txt files from other plugins for an example.


i get the below error when i compile my setup.nsi:

"Invalid command: CustomLicense::LoadFile"

have already included "nsDialogs.nsh"

thoughts ?


You need to either put the CustomLicense plugin dll into the NSIS\plugins directory, or you need to use !addplugindir at the top of your script.


well thanks, but where do i get this DLL from ? is that supposed to be bundled with NSIS 2.4, if yes, i was unlucky, it's not present in my plugins folder :(


Have you tried googling for 'customlicense plugin'?


just did :), and found it here:

http://nsis.sourceforge.net/CustomLicense_plug-in

thanks !


can't see my last URL ?

try this:

http://nsis.sourceforge.net/CustomLicense_plug-in


sorry guys, it doesn't let me display the URL !
@MSG, thanks for the hints.

i now have CustomLicense.dll in my plugin dir. i am able to get past the error. however, the EULA text box does not display the EULA, pls advise:

Function myLicensePageCreate
File /oname=EULA.txt "winst\EULA-en.rtf"
nsDialogs::CreateControl /NOUNLOAD ${__NSD_Text_CLASS} ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}|${ES_MULTILINE}|${WS_VSCROLL}|${WS_HSCROLL} ${__NSD_Text_EXSTYLE} 160 150 290 50
POP $0
CustomLicense::LoadFile "EULA.txt" "$0"
!include "winst\myLicense.nsh"
FunctionEnd


thanks a lot !

To prevent SPAM, your URL won't show, until you post certain number of posts.
Here's the link:
http://nsis.sourceforge.net/CustomLicense_plug-in

I think the plugin needs a absolute path.
Try CustomLicense::LoadFile "$INSTDIR\EULA.txt" "$0"


ok, thanks, that worked !
can i still use this functionality along with displaying the radio buttons at the bottom viz, "accept" and "decline" ?

and also, the Next button should remain enabled even when "decline" radio button is selected.


my apologies !
actually, it did not work :(
i am using the following code.


!define LICENSEPAGE "EULA-en.rtf"
ReserveFile "winst\${LICENSEPAGE}"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW "myLicensePageCreate"

....
Function myLicensePageCreate
InitPluginsDir
File /oname=${LICENSEPAGE} "winst\${LICENSEPAGE}"
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1000
CustomLicense::LoadFile "${LICENSEPAGE}" $0
!insertmacro MUI_HEADER_TEXT "$(MSG185)" "" #MSG# License Agreement
!insertmacro INSTALLOPTIONS_WRITE "myLicense.ini" "Field 1" "text" "$(MSG186)" #MSG# Press page down to see the entire EULA
!insertmacro INSTALLOPTIONS_WRITE "myLicense.ini" "Field 3" "text" "$(MSG187)" #MSG# You will have to accept the license agreement in order to proceed with the installation
!insertmacro INSTALLOPTIONS_WRITE "myLicense.ini" "Field 4" "text" "$(MSG188)" #MSG# I Accept
!insertmacro INSTALLOPTIONS_WRITE "myLicense.ini" "Field 5" "text" "$(MSG189)" #MSG# I Decline
!insertmacro INSTALLOPTIONS_DISPLAY "myLicense.ini"
FunctionEnd

Ok, you still need the full path.
Since I'm not sure if $INSTDIR is already defined when the function is called, you better use the pluginsdir (as used in my example script, like:

File "/oname=$PLUGINSDIR\${LICENSEPAGE}" "winst\${LICENSEPAGE}"
...
CustomLicense::LoadFile "$PLUGINSDIR\${LICENSEPAGE}" $0
Note that the UELA file will be deleted when the installer eds.

thanks, i'll try that. Before that but let me try understanding the need to have a CustomLicense plug-in.

can we still use it instead of :
!insertmacro MUI_PAGE_LICENSE "$(license_txt)"

the whole idea for me to have a custom license page is because i am not able to change the way MUI_PAGE_LICENSE behaves. ie. when i enable the radio buttons for i accept and i decline options, and "i decline" is selected, the "Next" button is disabled. I want it to be enabled to display the appropriate info to the customer about declining the license.

how can we achieve this ?
thanks in advance...:)


There is another plugin that seems to do what you require:

http://nsis.sourceforge.net/ScrollLicense_plug-in

"A plugin that stops the user passing the License page without scrolling to the end of the License box. Also has support for two "Accept" check-boxes when LicenseForceSelection checkbox is set."

Edit: Oops! I think I misread what you are trying to do, so this plugin may not be relevant.


I am trying to use the attached customlicense.nsi file, but I am not able to affect the Cancel and Close buttons that appear on the bottom of the screen. Is there any way to do so? I don't see any mention of these buttons in the script.


Hi, I find that it works well in Windows 7 but it doesn't work in Windows XP. (The customlicense plugin)
Can anybody help me? Thank you.


Try
http://forums.winamp.com/showthread.php?t=333267


nsRichEdit works on XP.

Stu


Originally posted by fifthnormal
Hello,

I have a textbox on a custom page:

${NSD_CreateText} 160 150 290 50 ''

I have a 24kb text file that I need to load into the text box.

I have use the CustomLicense plug-in before when using InstallOptions:
http://nsis.sourceforge.net/CustomLicense_plug-in

Is there a way to make CustomLicense work with nsDialogs. Or is there another way to get the file loaded in?

Thanks in advance,

Daniel
Such a very amazing link!

Quote:


I also think so.
__________________
Watch Zookeeper Online Free

Originally Posted by pengyou (Post 2568878) There is another plugin that seems to do what you require:


"A plugin that stops the user passing the License page without scrolling to the end of the License box. Also has support for two "Accept" check-boxes when LicenseForceSelection checkbox is set."

Edit: Oops! I think I misread what you are trying to do, so this plugin may not be relevant.