Archive: Two License Pages


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. :cry: 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

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


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

grmph - nice solution from the cvs i guess?
when will cvs go final :cry:


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

Try
!define MUI_CUSTOMFUNCTION_LICENSEPAGE_PRE LicenseText
instead of
!define MUI_CUSTOMFUNCTION_LICENSE_PRE LicenseText

-Stu


FindWindow, GetDlgItem and SendMessage are all present in b3 too.


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.

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


Yes.


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.


Attach the script and I'll have a look.


here is my script:

maybe it would be usefull to others to...


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.


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.


Hmm... Right. The window hasn't been created yet. You should use it in the show function not the pre function.


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 ? :D

thanks.


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.


sorry. i do not understand.

maybe with an example ? a little one ?


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.


i will try tonight. thanks very much. i'll tell you tomorow the result.
thanks again.


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!


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

it works. thanks.

then it should work for 3 licenses too ?


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.


@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.

:confused:

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

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


for kichik,

i tried (for the 3rd license page) but no result.
so for the moment it will remain so.


Can you attach the script?


Brummelchen, please attach large scripts from now on. o_owd answer is correct, you have to extract the file first and use full path.


for Joost:

Can you attach the script?
this question was for me? or Brummelchen?

does not work so far :(

After MUI_PAGE_WELCOME

MUI_PAGE_LICENSE
image
Page license "" "showLicense" "leaveLicense"
image
MUI_PAGE_COMPONENTS
image
then back to Page license
image

and so on ...

i always get the correct readme when i step back.

script is attached so far (sorry for inconvenience)


i don't know why it does not display the borh license pages.

try with this script. (it works in my script)


Greta move - u da man :D

it works. i have made a little change to get different pageheaders

> Page license "" "showLicense" "leaveLicense"
> Page license "" "showLicense1" "leaveLicense"

but one little teardrop

> !define MUI_LICENSEPAGE_CHECKBOX

no checkbox so far


Brummelchen, you have to use the MUI macros all the way if you are using the MUI. Using Page as a replacment for the MUI_PAGE_LICENSE macro is what causing you all of the problems above.

o_owd, please attach the script, or describe the logic you've tried to include 3 license pages.


@kichik

> !define MUI_LICENSEPAGE_CHECKBOX

exist there a MUI macro for that?

> or describe the logic you've tried to include 3 license pages.

I made an example to this, i hope that helps - it is based on the script from o_owd

The MUI section must be like this

> Page license "" "showLicense" "leaveLicense"
> Page license "" "showLicense1" "leaveLicense"
> Page license "" "showLicense2" "leaveLicense"
...

the first function is reduced 'cause it only displays the normal license.txt


No, "Using Page as a replacment for the MUI_PAGE_LICENSE macro is what causing you all of the problems above. "

MUI_LICENSEPAGE_CHECKBOX is a MUI define and is OK, but worth nothing if you don't use the MUI macro to insert the license page.


@kichik

So there is no alternative for that? Not a problem at all - the checkbox is only preventing from "klick - klick - klick - installed" must be "klick - read - check - klick - installed" ;)
But the other way dont work.

Is it possible to get the checkbox additional from InstallOption?


The other way is the only right way and it can work, you only need to find the right logic to make it show the right license in the right page. The logic implemented in my examples works for two pages that come one after the other. If you have another case you'd have to find another logic and implement it.


>> you only need to find the right logic to make it show the right license in the right page. The logic implemented in my examples works for two pages that come one after the other.

Thats what i am doing to - Welcome/license/readme
but so far i have no check button only the "accept" button.

to prevent misunderstandings...
you have a solution for that (2pages with check button) or not?


Archive: Two License Pages


Again, you don't have a check button because you have told the MUI to add a check button but haven't used the MUI's way of including pages, you have used the Page command.

The code I have attached above implements a logic to show two license pages that come one after another. All you need to do is translate it to MUI macros (change Page commands to the appropriate !insertmacro, define the right values, etc.)


for kichik,

i am trying to make a codec pack. there are a lots of them, so everybody knows what i'm talking about.
i try to include 3 license pages because there are 3 diffrent licenses:
the DivX codec has it's own license, then XviD and AC3 Filter are open source, so GNU license file, and Windows Media Player - Microsoft. so EULA is the 3rd.

for showing 2 of them i was using the code you showed me. but i need 3 of them. thanks to Brummelchen i have now 3 of them, but as you said - Page is just a replacement for MUI_PAGE_LICENSE.

so kichik, the logic was yours. you gave me the idea with "Page". why do i need 3 ? i just explained.
as for Brummelchen, is not my code, so the credit is not mine. it's kichik.

i'll attach the script. i think the script it's really nice, and maybe it will inspire others:

multiple license pages, custom page that appear only if one section was selected, as for uninstaller, it remembers what sections were installed. so it won't delete everything.

in a few words: everything that you helped me in the past few weeks.

really, a big thank you, man. to all of you.


Attached are two scripts that will hopefully clear this up. One with the MUI and one without. The one with the MUI uses the same show and leave function for all three pages and therefor requires a certain logic to know which page should be shown where the script without the MUI uses the Page command and therefor has a different show and leave function for every license page. The second script, using Page, doesn't require any logic because you know in which page you are by the function called.

Once again, do NOT use the Page command for non custom (Page custom - InstallOptions and such) in a MUI script! It's not only the checkbox missing, there's a lot more. Just don't.

The logic in the MUI script is required because you can't define a separate function for every license page but only one for all three. Therefor you must know in which page you're manually and not by the function called because there is just one function.

Last time, do NOT use Page license instead of !insertmacro MUI_PAGE_LICENSE in a MUI script.


you're the man. i'm done with this. thanks.