Archive: Dynamic finish page options


Dynamic finish page options
My product has two major applications as options during install. Let's just call them Server and Client. After installing one, or both, I would like to offer to launch them on the finish page. I can fudge the FINISHPAGE_SHOWREADME to relate to the Client (IE based), and FINISHPAGE_RUN is used for the Server App. However, I have yet to find a way to make this dynamic... If they only install the client, I don't want to have a checkbox to launch the Server App.
I thought MUI_WELCOMEFINISHPAGE_CUSTOMFUNCTION_INIT would let me change variables based on Sections before they are written to ioSpecial.ini, but I can't place:

!define MUI_PAGEMUI_FINISHPAGE_SHOWREADME "http://..."

in the custom init function. Any suggestions (short of writing to the ioSpecial.ini file itself)?
Specifically, can I define/undef MUI_FINISHPAGE_RUN dynamically?


MUI_FINISHPAGE_SHOWREADME is a defined symbol, not a variable.

You can hide the checkbox in a custom show function of the finish page. Find the inner window (see NSIS Users Manual, FindWindow) and use the control IDs 1202 and 1203.


My other option was to write them to the ini file myself in a custom pre function, but after browsing System.nsh I realized it would be tough to mimick the logic that arranges all the controls on the finish page.
Thanks for the tip!

By the way, System.nsh (Feb. 6 2004) has a typo in !macro MUI_PAGE_FINISH
This line...
!insertmacro MUI_UNSET MUI_FINISHPAGE_RUN_PARAMETES
...needs an 'R' in PARAMETERS.
Probably never cause an issue though, since it is for finish page only and the temp ini file is deleted right after this.
Thanks again!


Thanks, I'll fix that typo. It will indeed never cause any problems.


Word... got it workin'.
Tried to Find my main dialog first before getting the inner dialog - but this happened before the SHOW occured, so I got the page before the finish page and it did not have a control with id 1203 or 1204. (Spy++ said my controls were 1203 and 1204, not 1202 and 1203)
I just checked the trusty user manual and found that $MUI_HWND has already been set for me as the inner dialog's handle.
Also had to SendMessages LMBUTTONDOWN and LMBUTTONUP to uncheck them before I hide them. There's probably a better way, but it works. ;-)


That's correct, using $MUI_HWND is even easier :)

The ID is 1200 + Field Number - 1, so for field fields 4 and 5 it's indeed 1203 and 1204.


Hi coho,

can you please or someone else post an nsi script example of how you solved your problem?

I want to create a dynamic finish page but I can not do it:(.


First added these:

!define MUI_FINISHPAGE_LINK "Visit us on the web"
!define MUI_FINISHPAGE_LINK_LOCATION "http://homepage/"
!define MUI_FINISHPAGE_RUN "$INSTDIR\program.exe"
!define MUI_FINISHPAGE_RUN_TEXT "Launch Program"
!define MUI_FINISHPAGE_SHOWREADME "http://host/site"
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Launch the web service I just installed"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW SetFinishPageOptions ;hide the options if we did not install the corresponding component
!insertmacro MUI_PAGE_FINISH

My SHOW function for the finishpage is SetFinishPageOptions, and looks like this:

Function SetFinishPageOptions

IfRebootFlag 0 +2 ;if reboot flag has been set, our Launch options have been replaced.
Abort ;Don't hide the reboot radio buttons!

StrCmp $vInstallingWebService "yes" 0 hide_web
StrCmp $vInstallingProgram "yes" done hide_prog

hide_web:
GetDlgItem $2 $MUI_HWND "1204" ;control id gathered from Spy++. (1200 + Field number - 1)
SendMessage $2 ${WM_LBUTTONDOWN} 0 0 ;uncheck it
SendMessage $2 ${WM_LBUTTONUP} 0 0 ;
ShowWindow $2 ${SW_HIDE}
StrCmp $vInstallingNQSAdmin "yes" done hide_prog

hide_prog:
GetDlgItem $2 $MUI_HWND "1203" ;$MUI_HWND is defined for us by the MUI macros as the inner dialog hwnd
SendMessage $2 ${WM_LBUTTONDOWN} 0 0 ;uncheck it
SendMessage $2 ${WM_LBUTTONUP} 0 0 ;
ShowWindow $2 ${SW_HIDE}

done:

FunctionEnd

I set the $vInstalling variables in a MUI pre-function for the page called after the Components page. And remember, 1203 and 1204 are only because I have Link, Run, and Readme defined. Shrink by one for each that you leave out.

Sorry it took so long to reply!


P.S. Don't use ABORT in the above IfRebootFlag check, it will never show the finish page. Try Return. My bad.


I used:

IfRebootFlag done 0 ;

since I have the label 'done'.


Hi Coho,
Thanks a lot fo the cool code block which saved me when I had run out of all the other ways to achieve what you have done. However I think we can further refine the above script by introducing
!define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED before
!insertmacro MUI_PAGE_FINISH. This will allow us to get rid of extra SendMessage calls
SendMessage $2 ${WM_LBUTTONDOWN} 0 0 ;uncheck it
SendMessage $2 ${WM_LBUTTONUP} 0 0 ;
and have a more readable script.

Thanks a lot!


Hi there,
I'm trying a similar solution for the following scenario.

* My Finish page includes always a checkbox to select if you want or not run the application when you finish.
* When I'm installing in any OS different from WVista, I want to include also a checkbox to select if you want to create shortcut in the Desktop or not (I don't want to show this checkbox in Windows Vista). So I'm dynamically hidding it when I detect it's WVista.

My code is something like this:

!define MUI_PAGE_CUSTOMFUNCTION_SHOW HideDynamically
!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Shortcut in Desktop"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateShCtFunction
!insertmacro MUI_PAGE_FINISH


and my function to dinamically Hide the checkbox is something like


Function HideDynamically
Call GetWindowsVersion
Pop $R1
${If} $R1 == 'WVista'
FindWindow $2 "#32770" "" $HWNDPARENT ; Get inner dialog inside main window (the "white part" of the dialog)
GetDlgItem $2 $2 1204 ; Item 1204 -> "Create Shortcut in Desktop" checkbox control (id gathered from WinSpy++)
SendMessage $2 ${BM_CLICK} 0 0 ; uncheck it
ShowWindow $2 ${SW_HIDE} ; Hide it
${Endif}
Functionend


My problem is that MUI_PAGE_CUSTOMFUNCTION_SHOW is executed just before the Finish page is shown, so the dialog has not been painted yet. I have tried with MUI_PAGE_CUSTOMFUNCTION_LEAVE to check my code is working (and it works), but I cannot use "LEAVE" because it is executed when clicking on the finish button.

How could I do it to call the function just when the Finish dialog is shown? Or how can I access the check button if it doesn't exist yet? I have tried a lot of variations of the code above and it did not work :(

Thanks!


trouble
hi. i have tried ur code example and i cannot make it work. this is way to confusing for me. firstly i didn't know how to initialize var $vInstalling( "I set the $vInstalling variables in a MUI pre-function for the page called after the Components page"). my problem is that i have to say at the finish page, what programs were installed and what weren't. is there a special place i have to add the code "function SetfinishPageOptions"...help, pls?