vitalyb
16th June 2011 22:33 UTC
Prerequisites page? [With mockup]
Hi everyone,
I'm creating a setup for an application that requires multiple prerequisites. I've seen several samples in which the installer checks for a prerequisite, but in the samples I saw, it is either a simple messagebox or installation abort in case of missing prerequisite.
I am hoping to do something like described in the mockup above:
http://dl.dropbox.com/u/34935/Setup.png
The user can see what prerequisites he has, he can be directed to install them via a link and he can use the refresh button to verify the state of the prerequisites after an installation and after all the prerequisites are ready, the "Refresh" buttons turns to regular "Next" button (or "Next" is always there but disabled until a certain point).
Is there any page like that I can use? If not, how hard would be to write one that behaves that way?
I'm open to other suggestions too, anyone has a better idea on how I can do it with regular Modern UI pages?
Thanks!
Vitaly
Anders
16th June 2011 23:48 UTC
!include nsDialogs.nsh
page custom ChkPrqCreate ChkPrqLeave
!define PRQCOUNT 2
Var Prq1
Var Prq2
Function ChkPrqHelper
StrCpy $0 0
${NSD_UnCheck} $Prq1
${If} ${FileExists} "$temp\foo.txt"
IntOp $0 $0 + 1
${NSD_Check} $Prq1
${EndIf}
${NSD_UnCheck} $Prq2
${If} ${FileExists} "$temp\foo2.txt"
IntOp $0 $0 + 1
${NSD_Check} $Prq2
${EndIf}
GetDlgItem $1 $hwndparent 1
${NSD_SetText} $1 "$(^NextBtn)"
${If} $0 < ${PRQCOUNT}
${NSD_SetText} $1 "&Refresh"
${EndIf}
FunctionEnd
Function ChkPrqLeave
${If} $0 < ${PRQCOUNT}
call ChkPrqHelper
Abort
${EndIf}
FunctionEnd
Function ChkPrqCreate
nsDialogs::Create 1018
Pop $0
${NSD_CreateCheckBox} 0 13u 100% 13u "Thing #1 ($temp\foo.txt)"
Pop $Prq1
EnableWindow $Prq1 0
${NSD_CreateCheckBox} 0 30u 100% 13u "Thing #2 ($temp\foo2.txt)"
Pop $Prq2
EnableWindow $Prq2 0
Call ChkPrqHelper
nsDialogs::Show
FunctionEnd
...
T.Slappy
17th June 2011 08:36 UTC
Anders's script is fine but there should be some more components like Links.
But I am curious: what software you use to create such design?
vitalyb
17th June 2011 08:43 UTC
Anders' script helped me a lot. I'm rewriting it now to include links and bitmaps instead of checkboxes. I will post the result once I am done.
But I am curious: what software you use to create such design?
I've used
Balsamiq Mockups. It is really awesome for the task.
vitalyb
19th June 2011 10:26 UTC
Here is a solution what for I needed with images and clickable link. Hope it helps to someone:
Function .onInit
InitPluginsDir
File /oname=$PLUGINSDIR\x.gif "C:\Graphics\x.gif"
File /oname=$PLUGINSDIR\y.gif "C:\Graphics\y.gif"
FunctionEnd
!define PRQCOUNT 2
Var Prq1
Var Prq1Image
Var Prq2
Var Prq2Image
Function ChkPrqHelper
StrCpy $0 0
${NSD_UnCheck} $Prq1
${If} ${FileExists} "$temp\foo.txt"
IntOp $0 $0 + 1
${NSD_SetImageOLE} $Prq1 $PLUGINSDIR\y.gif $Prq1Image
${Else}
${NSD_SetImageOLE} $Prq1 $PLUGINSDIR\x.gif $Prq1Image
${EndIf}
${NSD_UnCheck} $Prq2
${If} ${FileExists} "$temp\foo2.txt"
IntOp $0 $0 + 1
${NSD_SetImageOLE} $Prq2 $PLUGINSDIR\y.gif $Prq2Image
${Else}
${NSD_SetImageOLE} $Prq2 $PLUGINSDIR\x.gif $Prq2Image
${EndIf}
GetDlgItem $1 $hwndparent 1
${NSD_SetText} $1 "$(^NextBtn)"
${If} $0 < ${PRQCOUNT}
${NSD_SetText} $1 "&Refresh"
${EndIf}
FunctionEnd
Function ChkPrqLeave
${NSD_FreeImageOLE} $Prq1Image
${NSD_FreeImageOLE} $Prq2Image
${If} $0 < ${PRQCOUNT}
call ChkPrqHelper
Abort
${EndIf}
FunctionEnd
!define CreatePrq "!insertmacro CreatePrq"
!macro CreatePrq Top Text LinkText LinkClickHandler PrqBitmap
; Bitmap top
StrCpy $1 ${Top}
IntOp $1 $1 + 1
${NSD_CreateBitmap} 0u $1u 100% 100% ""
Pop ${PrqBitmap}
${NSD_CreateLabel} 15u ${Top} 100% 10u "${Text}"
Pop $0
; LinkText Top
StrCpy $1 ${Top}
IntOp $1 $1 + 10
${NSD_CreateLink} 15u $1u 100% 10u "${LinkText}"
Pop $0
${NSD_OnClick} $0 ${LinkClickHandler}
!macroend
Function OnPrq1LinkClick
Pop $0 ; don't forget to pop HWND of the stack
ExecShell "open" "http://nsis.sf.net/1"
FunctionEnd
Function OnPrq2LinkClick
Pop $0 ; don't forget to pop HWND of the stack
ExecShell "open" "http://nsis.sf.net/2"
FunctionEnd
Function ChkPrqCreate
nsDialogs::Create 1018
Pop $0
${If} $0 == error
Abort
${EndIf}
${CreatePrq} 15u "Thing #1 ($temp\foo.txt)" "Bla Install it from here." OnPrq1LinkClick $Prq1
${CreatePrq} 45u "Thing #1 ($temp\foo.txt)" "Bla Install it from here." OnPrq2LinkClick $Prq2
Call ChkPrqHelper
nsDialogs::Show
FunctionEnd
TrifonovS
22nd June 2011 14:50 UTC
I made such dialog, based on your code. Thank you very much that you share it. Additionaly I want to skip this dialog completely if all prerequisites are ok. In that case there is no useful information for the user. So I changed the code a little bit like this:
${If} $0 < ${PRQCOUNT}
${NSD_SetText} $1 "&Refresh"
${Else}
Abort
${EndIf}
Now this dialog is skipped and on a first look everything seems to be ok, but if I go back from the next dialog, the installer crashes. Why it is so? What is the correct way to reach my goal?
Afrow UK
22nd June 2011 17:04 UTC
You need to call Abort before nsDialogs::Create or anything else.
Stu