- NSIS Discussion
- Reading a text file into a text box using nsdialog
Archive: Reading a text file into a text box using nsdialog
fifthnormal
20th December 2007 06:39 UTC
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
kichik
20th December 2007 16:59 UTC
CustomLicense should work as is with nsDialogs. Just give it the HWND you get from NSD_CreateText.
fifthnormal
22nd December 2007 03:55 UTC
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
fifthnormal
22nd December 2007 04:42 UTC
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"
Backland
23rd December 2007 06:34 UTC
Thanks for sharing :)
pospec
10th May 2008 10:35 UTC
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?
kichik
10th May 2008 10:43 UTC
Some styles must be there when you create the window or else they have no effect. That's probably one of them.
pospec
10th May 2008 13:18 UTC
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.
pospec
10th May 2008 13:47 UTC
This is my test:
pospec
10th May 2008 13:53 UTC
I got it :)
I forgot last argument - the string after the coordinates.
Icks92
14th September 2009 09:08 UTC
Where do we insert the text file to print in the text area ???
jpderuiter
14th September 2009 13:38 UTC
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
Icks92
14th September 2009 14:03 UTC
Thank youvery much for your answer but I add the double quotes and I have steel not text in my TextArea
Icks92
14th September 2009 14:17 UTC
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
Icks92
14th September 2009 16:21 UTC
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.
jpderuiter
14th September 2009 18:50 UTC
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.
sprinleo
21st September 2009 16:57 UTC
i get the below error when i compile my setup.nsi:
"Invalid command: CustomLicense::LoadFile"
have already included "nsDialogs.nsh"
thoughts ?
MSG
21st September 2009 16:58 UTC
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.
sprinleo
22nd September 2009 08:28 UTC
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 :(
MSG
22nd September 2009 08:38 UTC
Have you tried googling for 'customlicense plugin'?
sprinleo
22nd September 2009 08:49 UTC
just did :), and found it here:
http://nsis.sourceforge.net/CustomLicense_plug-in
thanks !
sprinleo
22nd September 2009 08:50 UTC
can't see my last URL ?
try this:
http://nsis.sourceforge.net/CustomLicense_plug-in
sprinleo
22nd September 2009 09:08 UTC
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 !
jpderuiter
22nd September 2009 15:07 UTC
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"
sprinleo
22nd September 2009 16:08 UTC
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.
sprinleo
22nd September 2009 16:38 UTC
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
jpderuiter
23rd September 2009 07:31 UTC
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.
sprinleo
23rd September 2009 11:07 UTC
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...:)
pengyou
23rd September 2009 20:29 UTC
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.
jrenbaum
16th March 2010 21:14 UTC
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.
grey220022
11th August 2011 11:31 UTC
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.
Afrow UK
11th August 2011 21:37 UTC
nsRichEdit works on XP.
Stu
bella10388
16th August 2011 08:39 UTC
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!
bella10388
16th August 2011 08:43 UTC
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.
|