ryangerard
14th September 2009 17:08 UTC
How can I make an NSIS image linkable in the installer?
I want to show a bitmap image that I can click on to open a link in my installer. I've been reading over the InstallOptions very closely:
http://nsis.sourceforge.net/Contrib/...ns/Readme.html
-You can create a "Button" that opens a link
-You can create a "Link" that opens a link
-You can create a "Bitmap" that shows an image
...but it doesn't look like you can create a Bitmap that opens a link when clicked, or a Button that uses a bitmap instead of the standard gray, square button. I tried messing around with the State and Text fields for some of these objects, and nothing was working. Any help you can provide?
Thanks!
Ryan
f0rt
21st September 2009 22:33 UTC
I would use nsDialogs instead of InstallOptions. nsDialogs gives you more flexibility.
nsis.sourceforge.net/Docs/nsDialogs/Readme.html
For a click-able image you would do something like the following:
"MUI2.nsh"
>OutFile "imglink.exe"
>Name "Image Link"
>InstallDir "$TEMPDIR"
>BrandingText " "
>; Background color
>!define BG_COLOR 0xffffff
Page custom nsImgLink
>!insertmacro MUI_LANGUAGE English
>Function .onInit
Push$0
InitPluginsDir
File/oname=$PLUGINSDIRfinish.bmp "${NSISDIR}\\Contrib\\Graphics\\Wizard\\orange-nsis.bmp"
>FunctionEnd
>Function OnClick
; Open link in web browser
ExecShell "open" "http://nsis.sourceforge.net"
>FunctionEnd
>Function nsImgLink
Push$0
Push$1
nsDialogs
::Create 1044
Pop$0
SetCtlColors$0 "" ${BG_COLOR}
${NSD_CreateBitmap} 0 0 165 315 ""
Pop $0
${NSD_SetImage} $0 $PLUGINSDIRfinish.bmp $1
Push$1
; Register handler for click events
${NSD_OnClick} $0 OnClick
${NSD_CreateLabel} 120u 32u -130u -32u "This is the end.$\\r$\\n$\\r$\\nClick on the image."
Pop $0
SetCtlColors$0 "" ${BG_COLOR}
; Hide branding text control
GetDlgItem$0 $HWNDPARENT 1028
ShowWindow$0 ${SW_HIDE}
; Hide separator
GetDlgItem$0 $HWNDPARENT 1256
ShowWindow$0 ${SW_HIDE}
nsDialogs::Show
Pop$1
${NSD_FreeImage} $1
Pop$1
Pop$0
FunctionEnd
Section
SectionEnd
>