Old 29th October 2012, 06:15   #1
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
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?
winman2004 is offline   Reply With Quote
Old 29th October 2012, 07:41   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
No. You'll have to create a custom page using nsDialogs.
http://nsis.sourceforge.net/Docs/nsDialogs/Readme.html
MSG is offline   Reply With Quote
Old 1st November 2012, 10:24   #3
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
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
winman2004 is offline   Reply With Quote
Old 1st November 2012, 13:33   #4
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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.
MSG is offline   Reply With Quote
Old 2nd November 2012, 07:15   #5
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
How to add choose install location box in in nsDialogs?
winman2004 is offline   Reply With Quote
Old 2nd November 2012, 07:29   #6
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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
MSG is offline   Reply With Quote
Old 2nd November 2012, 09:08   #7
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
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.
winman2004 is offline   Reply With Quote
Old 2nd November 2012, 09:13   #8
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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.
MSG is offline   Reply With Quote
Old 2nd November 2012, 09:38   #9
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
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)?

Last edited by winman2004; 2nd November 2012 at 10:54.
winman2004 is offline   Reply With Quote
Old 2nd November 2012, 11:21   #10
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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.
MSG is offline   Reply With Quote
Old 2nd November 2012, 12:17   #11
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
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??
winman2004 is offline   Reply With Quote
Old 2nd November 2012, 12:43   #12
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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.
MSG is offline   Reply With Quote
Old 2nd November 2012, 12:59   #13
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
Thank you.
winman2004 is offline   Reply With Quote
Old 3rd November 2012, 07:18   #14
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
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.
winman2004 is offline   Reply With Quote
Old 4th November 2012, 04:52   #15
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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...
MSG is offline   Reply With Quote
Old 5th November 2012, 13:15   #16
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
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
winman2004 is offline   Reply With Quote
Old 5th November 2012, 20:14   #17
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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
MSG is offline   Reply With Quote
Old 7th November 2012, 03:49   #18
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
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?
winman2004 is offline   Reply With Quote
Old 7th November 2012, 05:07   #19
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,163
Fonts don't store color information, setting the text color with SetCtlColors on the link control handle should work...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 7th November 2012, 05:18   #20
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
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
winman2004 is offline   Reply With Quote
Old 7th November 2012, 13:32   #21
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
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.
winman2004 is offline   Reply With Quote
Old 7th November 2012, 15:36   #22
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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.
MSG is offline   Reply With Quote
Old 8th November 2012, 07:20   #23
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
Quote:
Originally Posted by MSG View Post
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?
winman2004 is offline   Reply With Quote
Old 8th November 2012, 07:45   #24
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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.
MSG is offline   Reply With Quote
Old 8th November 2012, 10:34   #25
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
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.
Attached Files
File Type: nsi dummy.nsi (8.5 KB, 246 views)
winman2004 is offline   Reply With Quote
Old 8th November 2012, 12:13   #26
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
I actually already answered your first question:
Quote:
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
MSG is offline   Reply With Quote
Old 8th November 2012, 13:36   #27
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
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.
winman2004 is offline   Reply With Quote
Old 8th November 2012, 15:21   #28
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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.)
MSG is offline   Reply With Quote
Old 9th November 2012, 04:06   #29
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
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?
winman2004 is offline   Reply With Quote
Old 9th November 2012, 04:56   #30
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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 )
MSG is offline   Reply With Quote
Old 10th November 2012, 03:33   #31
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
I have done all the changes you have mentioned here and it is working fine now.
Thank you..MSG...
winman2004 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump