Skip to content
⌘ NSIS Forum Archive

Two License Pages

44 posts

gek#

Two License Pages

Hi,

I'm very new to NSIS and I'm trying to figure out how to make an installer that displays 2 license pages that follow each other using Modern UI. I tried something like


LicenseData "[snip long absolute path]\gpl.txt"

!insertmacro MUI_PAGECOMMAND_WELCOME
!insertmacro MUI_PAGECOMMAND_LICENSE

LicenseData "[snip long absolute path]\warning.txt"

!insertmacro MUI_PAGECOMMAND_LICENSE
!insertmacro MUI_PAGECOMMAND_DIRECTORY
!insertmacro MUI_PAGECOMMAND_STARTMENU
!insertmacro MUI_PAGECOMMAND_INSTFILES
!insertmacro MUI_PAGECOMMAND_FINISH
but it does not seem to work. 😢 Could someone help me with this issue??

One more question: Can I somehow display RTF files in the license box? It's not really necessary, but it would be nice to have.

Thanks for the great installer, btw.!!

Greets,
Daniel
Brummelchen#
i am not sure - this might same problem with an additional readme section which is on the to-do-list.
search the forum for "readme" and you will find no answer ;(

# i forgot
there exist a extlicense.dll or so - i found the SC on this site, but no DLL - dont know how to compile
Afrow UK#
You will need to do the following:


LicenseData "[snip long absolute path]\gpl.txt"

!insertmacro MUI_PAGECOMMAND_WELCOME
!insertmacro MUI_PAGECOMMAND_LICENSE
!define MUI_CUSTOMFUNCTION_LICENSE_PRE LicenseText
Page license mui.LicensePre mui.LicenseShow mui.LicenseLeave "MUI_INSTALLBUTTON_LICENSE"


Function LicenseText
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $1 $0 102 #change
SendMessage $1 ${WM_SETTEXT} 0 "STR:License Text$\r$\nLine 1$\r$\nLine 2$\r$\nLine 3" #change
FunctionEnd
You now need to get the License text on one line into the command, and you also might need to get the right dialog number (currently 102)
However, I think I have the right dialog number there?
Change the dialog number until the license text within the window changes.

-Stu
gek#
Hi,

Thanks for your answer. I'm almost there! I now get the license page twice, but unfortunatly both time with the same license. When I compile the NSI I get the warning:


1 warning:
install function "LicenseText" not referenced - zeroing code (298-301) out
I don't quite understand. Perhaps you could have a look at the script?

Thanks in advance,
Daniel
Afrow UK#
Try
!define MUI_CUSTOMFUNCTION_LICENSEPAGE_PRE LicenseText
instead of
!define MUI_CUSTOMFUNCTION_LICENSE_PRE LicenseText

-Stu
kichik#
Re: Two License Pages

Originally posted by gek
One more question: Can I somehow display RTF files in the license box? It's not really necessary, but it would be nice to have.
Yes, you can. Just specify an RTF file instead of a text file in LicenseData.
Afrow UK#
Will LicenseData ever become a non compiletime command?
I mean, so that it can be used multiple times to change the LicenseData on multiple LicensePages.

That would be a helpful feature.

-Stu
o_owd#
hi!

i have a similar problem...
i need to show 2 licence pages. i followed the steps (as explained in this tread), and i have 2 license pages, but with the same content (from LicenseData "txt.txt"). i have no errors or warnings. help !

thanks.
o_owd#
here is my script:

maybe it would be usefull to others to...
kichik#
Change:
GetDlgItem $1 $0 102 #change
to:
GetDlgItem $1 $0 1000

You will also need a way to determine that the LicenseText function was called for the right page, as it will be called for both the license pages. You should probably set a variable to 1 in the page's leave function and then if it's set in the pre function change the text and reset the variable. This way you will only see the first license when the variable is not set which is when the user comes back from the second page to the first page. I'm assuming here that the two pages come right after the other, as in your script. If this is not the case anymore you will have to set the variable in other pages too to know which page you should show next.
o_owd#
i changed "GetDlgItem $1 $0 102 #change" with "GetDlgItem $1 $0 1000" but i still have 2 pages with the text from LicenseData displayed.

thanks.
kichik#
Hmm... Right. The window hasn't been created yet. You should use it in the show function not the pre function.
o_owd#
a little help please!

where to put the variable ? in what section ? i must create a new one ?
and in what section to check the state of the variable, and change it ?

and the most important !
how do i declare one ? 😁

thanks.
kichik#
Not a section, in the pre/show/leave functions of the pages. You don't need to declare one, just use $0, $1, ..., or $R9. This variable is meant for the LicenseText function to know in which page it is so it won't show the same text on both pages. In your case setting it on the leave function of the license page and clearing (and checking) it in the show function should be enough.
kichik#
I have used the same pre, show and leave functions for both of the license pages because that's how it works with the MUI.
o_owd#
hi!

i tried and tried and finaly it works. but one big question:
the first license page displayes "LicenseData" while for the second one i have to write manualy in the script every line. but what if i have a license about 10KB ? is it posible to display in the second page too, the license from a file ?

thanks again!
kichik#
Use this instead of the SendMessage ${WM_SETTEXT} command:

SendMessage $0 ${WM_SETTEXT} 0 "STR:"
FileOpen $1 "$PLUGINSDIR\secondlicense.txt" "r"
loop:
FileRead $1 $2
SendMessage $0 0x00C2 0 "STR:$2"
IfErrors 0 loop
FileClose $1
SendMessage $0 0x00B1 0 0
SendMessage $0 0x00B7 0 0
kichik#
If you apply the right checking in the show and leave functions. It shouldn't be too hard, just keep in mind that the leave function is only called when the user clicks next and not on back or cancel.
Brummelchen#
@kichik

same problem here - i have no idea - not familiar with this:
!include WinMessages.nsh

;--------------------------------
;Modern UI Configuration

!insertmacro MUI_PAGE_WELCOME

!insertmacro MUI_PAGE_LICENSE
!define MUI_LICENSEPAGE_CHECKBOX
Page license "" "showLicense" "leaveLicense"

!insertmacro MUI_PAGE_COMPONENTS
!define MUI_COMPONENTSPAGE_SMALLDESC

!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_PAGE_FINISH
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED "$INSTDIR\readme.txt"

!define MUI_ABORTWARNING

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

;--------------------------------
;Data

LicenseData "license.txt"

;--------------------------------
;Reserve Files

ReserveFile "readme.txt"

;--------------------------------
;Installer Functions

Function showLicense
StrCmp $R9 1 0 skip
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1000

SendMessage $0 ${WM_SETTEXT} 0 "STR:"
FileOpen $1 "readme.txt" "r"
loop:
FileRead $1 $2
SendMessage $0 0x00C2 0 "STR:$2"
IfErrors 0 loop
FileClose $1
SendMessage $0 0x00B1 0 0
SendMessage $0 0x00B7 0 0

skip:
StrCpy $R9 0
FunctionEnd

Function leaveLicense
StrCpy $R9 1
FunctionEnd

;--------------------------------
I get twice the License-Page with nail [x] and when i reached the compo-page and step one step back i get my readme in a small (license) window and a nail. step back once more and repeat from license page same procedure.

😕

##
second problem - i get no option for the readme at the end. cvs-problem? 2b3 did so. Or just again the MUI?
o_owd#
try changing like this:

FileOpen $1 "readme.txt" "r" to FileOpen $1 "$PLUGINSDIR\readme.txt" "r"

and you must have this:

Function .onInit
InitPluginsDir
File /oname=$PLUGINSDIR\readme.txt "readme.txt"
FunctionEnd

hope it will help
o_owd#
for kichik,

i tried (for the 3rd license page) but no result.
so for the moment it will remain so.
kichik#
Brummelchen, please attach large scripts from now on. o_owd answer is correct, you have to extract the file first and use full path.