- NSIS Discussion
- Two License Pages
Archive: Two License Pages
gek
28th May 2003 19:07 UTC
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
Brummelchen
28th May 2003 22:06 UTC
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
28th May 2003 22:08 UTC
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
Brummelchen
28th May 2003 22:15 UTC
grmph - nice solution from the cvs i guess?
when will cvs go final :cry:
gek
28th May 2003 23:33 UTC
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
28th May 2003 23:42 UTC
Try
!define MUI_CUSTOMFUNCTION_LICENSEPAGE_PRE LicenseText
instead of
!define MUI_CUSTOMFUNCTION_LICENSE_PRE LicenseText
-Stu
kichik
29th May 2003 10:02 UTC
FindWindow, GetDlgItem and SendMessage are all present in b3 too.
kichik
31st May 2003 14:55 UTC
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
31st May 2003 17:23 UTC
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
kichik
31st May 2003 17:27 UTC
Yes.
o_owd
2nd June 2003 10:46 UTC
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.
kichik
2nd June 2003 13:36 UTC
Attach the script and I'll have a look.
o_owd
2nd June 2003 13:43 UTC
here is my script:
maybe it would be usefull to others to...
kichik
2nd June 2003 13:54 UTC
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
2nd June 2003 14:26 UTC
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
2nd June 2003 14:31 UTC
Hmm... Right. The window hasn't been created yet. You should use it in the show function not the pre function.
o_owd
2nd June 2003 15:20 UTC
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.
kichik
2nd June 2003 15:26 UTC
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.
o_owd
2nd June 2003 15:47 UTC
sorry. i do not understand.
maybe with an example ? a little one ?
kichik
2nd June 2003 15:57 UTC
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
2nd June 2003 16:12 UTC
i will try tonight. thanks very much. i'll tell you tomorow the result.
thanks again.
o_owd
3rd June 2003 12:30 UTC
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
3rd June 2003 12:57 UTC
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
o_owd
3rd June 2003 13:41 UTC
it works. thanks.
then it should work for 3 licenses too ?
kichik
3rd June 2003 13:53 UTC
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
3rd June 2003 14:54 UTC
@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?
o_owd
3rd June 2003 15:02 UTC
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
3rd June 2003 15:29 UTC
for kichik,
i tried (for the 3rd license page) but no result.
so for the moment it will remain so.
Joost Verburg
3rd June 2003 18:28 UTC
Can you attach the script?
kichik
3rd June 2003 18:41 UTC
Brummelchen, please attach large scripts from now on. o_owd answer is correct, you have to extract the file first and use full path.
o_owd
3rd June 2003 21:31 UTC
for Joost:
Can you attach the script?
this question was for me? or Brummelchen?
Brummelchen
3rd June 2003 21:51 UTC
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)
o_owd
4th June 2003 06:48 UTC
i don't know why it does not display the borh license pages.
try with this script. (it works in my script)
Brummelchen
4th June 2003 16:19 UTC
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
kichik
4th June 2003 20:35 UTC
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.
Brummelchen
4th June 2003 20:58 UTC
@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
kichik
4th June 2003 21:02 UTC
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.
Brummelchen
4th June 2003 21:25 UTC
@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?
kichik
4th June 2003 21:42 UTC
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.
Brummelchen
4th June 2003 22:29 UTC
>> 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?
- NSIS Discussion
- Two License Pages
Archive: Two License Pages
kichik
4th June 2003 22:37 UTC
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.)
o_owd
5th June 2003 07:21 UTC
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.
kichik
5th June 2003 14:07 UTC
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.
o_owd
5th June 2003 14:24 UTC
you're the man. i'm done with this. thanks.