Archive: NSIS install pages


NSIS install pages
I found NSIS easy to create installation pages.Now i have a welcome page,user agreement page,choose directory page etc in different pages.How can i create a installation with welcome page,user agreement and choosing path for installation in single page in a simple way? Any template for this design?


No. You'll have to create a custom page using nsDialogs.
http://nsis.sourceforge.net/Docs/nsDialogs/Readme.html


where should i do the coding of nsdialogs? Right now i am using default installer pages with welcome page,licence page etc for which i have !insertmacro MUI_PAGE_WELCOME etc in my nsi file.But if i use the nsdialogs then should i use MUI_PAGE_WELCOME etc macros?
Where to include the code of nsDialogs?If you have any example please let me know.If possible plz give reference of a full script which uses all types of nsdialogs so that i can understand it easily..
Thank you


There's an excellent tutorial in the nsDialogs readme. You can simply add a 'page custom yourpagefunction' inbetween your MUI page macro calls.

In your custom page function you can use the MUI_HEADER_TEXT macro just before you call nsDialogs::show to set the page's header text.


How to add choose install location box in in nsDialogs?


It's best to use a DIRECTORY page for setting install locations. If you need a second install location, use a second directory page with the MUI_DIRECTORYPAGE_VARIABLE define. (And perhaps MUI_DIRECTORYPAGE_TEXT_DESTINATION and MUI_DIRECTORYPAGE_TEXT_TOP defines.)
http://nsis.sourceforge.net/Docs/Mod...02/Readme.html

But if you still want your own directory field, use NSD_CreateDirRequest.
http://nsis.sourceforge.net/Docs/nsD...ml#mref-create


I was able to add directory for installation in nsdialog.how can i add custom license page?Can i add it by using nsdialog?I want to add licence in same page as directory selection page.


Yes, you can create your own custom page with nsDialogs, that's what it's for. But note that both the standard MUI license page and directory page do some very fancy stuff that is not easy to reproduce. Things like install folder verification, free space check, richtext rendering, etc...

I once created my own directory page, and it was a lot of work. You're probably better off using two standard pages separately.


Ok so i think its difficult to include both licence page and directory page together.but i think i can do welcome page and directory for installation can be combined in same page.Now i already have standard welcome page.How i can include directory selection in same page easily?Can i change the standard page script?if possible how?

Also how to add scroll bar for a text field in nsdialog(like in the licence agreement)?


The MUI2 welcome page is a purely nsDialogs page, you can find the code in NSIS\Contrib\ModernUI2\pages\welcome.nsh (or whatever it's called, my memory isn't perfect). You can either copy and edit this code, or you can use the page's SHOW function to add some elements manually.


What is the major changes in mui.nsh and mui2.nsh? Now i am using mui.nsh. If i want to use mui2.nsh then what changes i should do(in mui 2.nsh document i got like "The interface settings provided by the NSIS compiler itself (such as LicenseText, Icon, CheckBitmap, InstallColors) should not be used in Modern UI scripts.")
So should i change anything?
If i use mui2.nsh then should i remove reference to mui.nsh(!include mui.nsh required or not?)
I tried copying welcome.nsh from the path u specified to my script path and added one extra label. i also included !include welcome.nsh in script.When compiling i got error like "!macro:macro named "MUI_WELCOMEPAGE_INTERFACE" already found!".Can u please help me on all of these errors??


All you need to do is replace !include MUI.nsh with !include MUI2.nsh.

Don't include welcome.nsh directly. Either copy its (nsDialogs) page design code to your own custom page function, or use the MUI macro to insert the official welcome page.


Thank you.


I have copied the nsdialogs from welcome.nsh to my script.When i compile i got error like Error:resolving install function "Call${MUI_PAGE_UNINSTALLER_FUNCPREFIX}muiPageLoadFullWindow" in function "${pre}"
I have copied only nsdialog from macro MUI_FUNCTION_WELCOMEPAGE PRE LEAVE.


Don't just blatantly copy code you don't fully understand... The functionname "${MUI_PAGE_UNINSTALLER_FUNCPREFIX}muiPageLoadFullWindow" cannot be found by the compiler. This is logical, because you don't even have that function.

All you should copy from welcome.nsh is things like
${NSD_CreateBitmap} 0u 0u 109u 193u ""
Pop $mui.WelcomePage.Image
${NSD_SetStretchedImage} $mui.WelcomePage.Image $PLUGINSDIR\modern-wizard.bmp $mui.WelcomePage.Image.Bitmap
Of course, you would need to change all the ${MUI_ETC} defines to actual values. ${MUI_WELCOMEPAGE_TITLE_HEIGHT} would be 28, ${MUI_WELCOMEPAGE_TEXT_TOP} would be 45, etc...


I was able to do custom page using nsdialog. But how to set background color and font color as different colors? I am trying to add a link in welcome page for which i want text color other than black but i want background color of text white only.
${NSD_CreateLink} 200u 70u 65u 14u "license agreement"
Var /GLOBAL LINK
Pop $LINK
SetCtlColors $LINK "" "ffffff"
CreateFont $LINK.Font "$(^Font)" "8" "500"
SendMessage $LINK ${WM_SETFONT} $LINK.Font 0
${NSD_OnClick} $LINK onClickMyLink

here SetCtlColors $LINK "" "ffffff" makes background white,but i am not getting how to change color of text which is a link..plz help me


Why don't you just set the text color with the same setctlcolors command..?
http://nsis.sourceforge.net/Docs/Cha...html#4.9.14.15


i tried using using color for font in links.But didnt work for me
${NSD_CreateLink} 200u 70u 65u 14u "license agreement"
Var /GLOBAL LINK
Pop $LINK
SetCtlColors $LINK "" "ffffff"
CreateFont $LINK.Font "$(^Font)" "08" "500" /UNDERLINE
SetCtlColors $LINK.Font "" "F5DEB3"
SendMessage $LINK ${WM_SETFONT} $LINK.Font 0
${NSD_OnClick} $LINK onClickMyLink

But above code didn't change color of word "license agreement".
Can you tell me how to set color for text of a link?


Fonts don't store color information, setting the text color with SetCtlColors on the link control handle should work...


But does my code will work? Because i didn't get the color for link.
this one worked for me and i was able to change font size
CreateFont $LINK.Font "$(^Font)" "08" "500" /UNDERLINE

But SetCtlColors $LINK.Font "" "F5DEB3" didn't change the font.
i doubt something wrong with my coding!!Please help me


I want to add a button or checkbox to make user to change installation folder for my application.If they select check box then only another installation page should appear with option for changing installation path.If check box is not selected the installation should be continued to default path.How i can do this by using nsdialog or any other option in nsis.


1) In the checkbox page's leave function, store the state of the checkbox into a variable.
2) In your directory page's pre function, call 'abort' if the variable is not set. This will make NSIS skip the directory page.


Originally posted by MSG
1) In the checkbox page's leave function, store the state of the checkbox into a variable.
2) In your directory page's pre function, call 'abort' if the variable is not set. This will make NSIS skip the directory page.
Should i change pre function of Directory.nsh of NSIS\Contrib\Modern UI 2\Pages path Or can i do it in my nsis script.now i have something like this
Function nsDialogsPageLeave

${NSD_GetText} $Text $Text_State
${NSD_GetState} $Checkbox $Checkbox_State
${If} $Checkbox_State == ${BST_CHECKED}
;script to open directory page

${EndIf}
FunctionEnd

can i do any coding to open a directory page in the above code.i think i cannot call "call directory" in this case.any idea to do it?or any alternative?

You need to make your own prefunction. For a MUI page, use the MUI define:
!define MUI_PAGE_CUSTOMFUNCTION_PRE YourPreFunction
!insertmacro MUI_PAGE_DIRECTORY

Or, if this is a custom page, simply call abort in your normal page function, before you do nsDialogs::create.

As for your code example: You should not try to call a page. Instead, skip the page if you don't need it.


How to abort or skip a page in nsdialog?
Also what does these pre function you told do?How to handle it?
I have attached a nsi file(it is a dummy installation in which i was trying to do custom pages)
I was not able to skip pages in nsDialogsPageLeave function.Please help me.


I actually already answered your first question:

Or, if this is a custom page, simply call abort in your normal page function, before you do nsDialogs::create.
You can read about pre, show and leave functions here: http://nsis.sourceforge.net/Docs/Chapter4.html#4.5.3
Like I said, two times already: Do not try to skip pages in a leave function. Just call abort in a page's PRE function to skip it.

The script you supplied doesn't make any sense to me. First of all it's a pile of spaghetti, but I also only see one page being created. If there's no second page to skip, how are you expecting to skip it? o_O

hi...MSG.
The script i posted had only welcome page and finish page.My plan was to add change destination folder in welcome page by giving check box for user.If he selects it then only directory page will appear.Also now using skipping of pages i am able to do what i wanted.Now my installation became easy with welcome page which also includes license and change directory and a finish page.Thank u for your help.


No problem, glad you got it working. Please try to keep your code clean. :)


Edit: (Actually, I'm not entirely sure if in a custom page function you should call abort. Perhaps instead you should just put all the nsDialogs code inside a big ${If} statement. I can't remember for sure. Just see what works for you.)


yeah..i used abort to skip page.what i did is for directory page

Page custom InstallPageCreate checkinstdir
Page directory skippage ""

Function InstallPageCreate
;nsdialog script for welcome page and also a check box whether to change directory
${NSD_CreateCheckbox} 120u 90u 100% 10u "&Change installation directory"
Pop $CheckBox
CreateFont $CheckBox.Font "$(^Font)" "08" "500"
SetCtlColors $CheckBox "" "FFFFFF"
SendMessage $CheckBox ${WM_SETFONT} $CheckBox.Font 0
FunctionEnd

Function checkinstdir
${NSD_GetText} $Text $Text_State
${NSD_GetState} $Checkbox $Checkbox_State
${If} $Checkbox_State == ${BST_CHECKED}
strcpy $checked 1
${Endif}
FunctionEnd

Function skippage
strcmp $checked 1 my1 close1
close1:
abort
my1:
FunctionEnd

This one worked for me.Do you have any better idea or suggestions?


Looks good, but you should add an Else to your checkinstdir function. If the user clicks Back and then disables the checkbox, the installer shouldn't skip the directory page anymore.

Also, add this after pop $checkbox:
${If} $Checkbox_State == ${BST_CHECKED}
${NSD_Check} $Checkbox
${EndIf}
This way, the user's choice will be shown properly if the user clicks Back. (See also the Memory section of the nsDialogs manual: http://nsis.sourceforge.net/Docs/nsD...ml#step-memory )


I have done all the changes you have mentioned here and it is working fine now.
Thank you..MSG...