Archive: Ask user about desktop shortcut?


Ask user about desktop shortcut?
Hi!

I am novice in Installation development and have following problem:
I need to ask user about creation of the desktop shortcut of my application on his deskstop. Is there any standard way to do this? Some example script which demonstrates such behavior would be a perfect. I didn't find some on NSIS page :(
I add pages as follows:

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "license.rtf"

!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH

Alex.


You could use MUI_FINISHPAGE_RUN_FUNCTION for this, (see MUI documentation) or build a custom page if you prefer.


Thanks!


I tryied to make this by following code:


; 2 Checkboxes for Quick launch and Desktop.
!define MUI_PAGE_CUSTOMFUNCTION_PRE CreateControls
!define MUI_PAGE_CUSTOMFUNCTION_SHOW SetControlColours
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE DisplayQuickLaunchAndDesktopIcon
!insertmacro MUI_PAGE_FINISH

.....

Function CreateControls

; Quicklaunch short cut.
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Settings" "NumFields" "6"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Type" "CheckBox"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Text" "&Add to quick launch"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Left" "120"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Right" "-10"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Top" "130"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Bottom" "142"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "State" "1"

; Desktop short cut.
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Settings" "NumFields" "7"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Type" "CheckBox"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Text" "&Add to desktop"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Left" "120"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Right" "-10"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Top" "144"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "Bottom" "156"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 7" "State" "1"

FunctionEnd

Function SetControlColours
ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 6" "HWND"
SetCtlColors $0 0x000000 0xFFFFFF
ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 7" "HWND"
SetCtlColors $0 0x000000 0xFFFFFF
FunctionEnd

Function DisplayQuickLaunchAndDesktopIcon
ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 6" "State"
StrCmp $0 "0" end
CreateShortCut "$QUICKLAUNCH\${prodname}.lnk" "$INSTDIR\${exec}" "" "$INSTDIR\${icon}"
end:
ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 7" "State"
StrCmp $0 "0" finish
CreateShortCut "$DESKTOP\${prodname}.lnk" "$INSTDIR\${exec}" "" "$INSTDIR\${icon}"
finish:
FunctionEnd



That's ok for me, but there is another problem: two these checkboxes appear not instantly on FINISH_PAGE is shown, but after some timeout or thay can appear only when I move mouse over the finish page window. What I did wrong?

Sounds like another control such as a label is covering them up.

Stu


and then what can be done to make it ok?


Check the ioSpecial.ini file at run time to identify which other field has a Bottom value that is negative or over 130.

Stu


Why not use the standard finish page checkboxes?


Unfortunatly, I didn't see them on default finish page. How make them active and visible? Is there any example maybe?


Check the Modern UI Readme for the finish page settings to enable them. The default functions run an application or show a Readme file when the box is checked, but with custom functions you can link any action you want.


Re: Ask user about desktop shortcut?

Originally posted by creatman
I need to ask user about creation of the desktop shortcut of my application on his deskstop. Is there any standard way to do this?
If you had a components page you could just put the code to create the shortcut in a separate section, and it would automatically appear among the components to be installed, with a checkbox the user could select or clear. It's probably a bit much to add a components page when the only options are "The application" and "A desktop shortcut"!

Another very easy approach would be to use a YES/NO MessageBox to ask the question. It wouldn't look quite a neat as, for example, adding a checkbox to the finish page, but would be really easy.

I know how to offer desktop shortcuts in place of the readme, but I'm puzzled that Modern UI doesn't already allow a third checkbox for desktop shortcuts. Can someone explain that?