Examples, Tips and
Troubleshooting
|
We have developed several examples which are ready for instant
start with Graphical Installer (can be found in
${NSISDIR}\Graphical Installer\Examples
folder):
Basic
example - This is basic example for Graphical Installer.
Basic example (graphics) - file with graphic settings for Basic
example.
Install Designer example - This example shows how to integrate
dialog(s) created with Install Designer tool with Graphical
Installer.
Install Designer example (graphics) - file with graphic
settings for Install Designer example.
Skin
example - This example demonstrates using of OLE images (.jpg
.gif .bmp) for background image.
Skin example (graphics) - file with graphic settings for Skin
example.
RTL Languages example - This example demonstrates creating
installer with support for RTL languages. Script files should be
saved in UTF-16 encoding.
If you are using NSIS 2.46 or older then you need to use an Unicode
build of NSIS to view languages correctly Recommended: http://www.scratchpaper.com/.
NSIS 3 (since 3.0a0) has command Unicode
(true/false) which can turn creating Unicode installers on and off
so there is no problem with Unicode languages.
RTL Languages example (graphics) - file with graphic settings
for RTL example.
nsDialogs
example - This example demonstrates using of nsDialogs together
with Graphical Installer.
nsDialogs example (graphics) - file with graphic settings for
nsDialogs example.
InstallOptions example - This example demonstrates using of
InstallOptions together with Graphical Installer.
InstallOptions example (graphics) - file with graphic settings
for InstallOptions example.
Print and Save example - This example demonstrates creating of
installer with possibility to Print and Save License file.
Print and Save example (graphics) - file with graphic settings
for Print and Save example.
Multiple Backgrounds example - This example demonstrates using
of Multiple OLE images (.jpg .gif .bmp) for background image.
Multiple Backgrounds example (graphics) - file with graphic
settings for Multiple Backgrounds example.
Visual & Installer example - This example demonstrates
integrating NSIS into Microsoft Visual Studio (any version).
Visual & Installer example (graphics) - file with graphic
settings for Visual & Installer example.
RAD
& Installer example - This example demonstrates integrating
NSIS into Embarcadero RAD Studio (any version).
RAD & Installer example (graphics) - file with graphic
settings for RAD & Installer example.
Irregular Form example - This example demonstrates creating non
rectangular forms (forms with transparent areas).
Irregular Form example (graphics) - file with graphic settings
for Irregular Form example.
Start menu example - This example demonstrates creating Start
menu page with Graphical Installer.
Start menu example (graphics) - file with graphic settings for
Start menu example.
Visual_UI
example - This example demonstrates VisuaL_UI feature -
creating 'Visual Studio Setup' like design of installers without
any pictures - by using colors only.
Visual_UI example (graphics) - file with graphic settings for
VisuaL_UI example.
Drag and Drop example - This example demonstrates Drag &
Drop installation page (page without buttons where user needs to
drag image and drop it on target to continue installation).
Drag and Drop example (graphics) - file with graphic settings
for Drag and Drop example.
In next section you can find several situations which can occur in
your installer and solutions for them.
Solution:
Use ${GraphicalInstallerRedrawnsDialogsPage}
symbol into each nsDialogs page creator's function.
This symbol should be inserted just before nsDialogs::Show
(so everything is initialized correctly). It calls appropriate
macro to redraw the dialog correctly.
See the nsDialogs
example for more details.
For InstallOptions pages (officially deprecated) use the
${GraphicalInstallerRedrawInstallOptionsPage}
macro. This macro requires 1 parameter which is image control
HWND.
See the
InstallOptions example for more details.
Solution:
Use ${GraphicalInstallerRedrawCONTROL}
symbol to set transparency on such controls. This macro requires 1
parameter which is control HWND. CONTROL can be one of
these:
Label: Redraws label (no result)
CheckBox: Redraws CheckBox (result is stored in $R9)
RadioButton: Redraws RadioButton (result is stored in
$R9)
Example:
# Create CheckBox control
Var /Global CHECKBOX
${NSD_CreateCheckbox}
0 -50
100% 8u
Test
Pop $CHECKBOX
# Apply transparent redrawing to
control
${GraphicalInstallerRedrawCheckBox}
$CHECKBOX # $CHECKBOX contains control HWND
# $R9 contains result (you can check
this result and show message on error)
If you need to call some function for some page in its PRE or
SHOW usually you would use !define MUI_PAGE_CUSTOMFUNCTION_SHOW MyFunction
But this SHOW function is already used for redrawing page in
Graphical Installer. Use this piece of code to keep both - your and
Graphical Installer's function active:
!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyFunction
Function MyFunction
# Call GraphicalInstallerRedraw to
redraw page
Call GraphicalInstallerRedraw
# Continue with your code
here...
FunctionEnd
If you want to use your custom .onGUIInit function you need to
'overwrite' the onGraphicalInstallerGUIInit function. See the
Irregular Form example for details.
; As Graphical Installer defines custom
MUI_CUSTOMFUNCTION_GUIINIT function it is necessarry to overwrite
it
; Put this code after line: !include
"${NSISDIR}\\Graphical
Installer\\GraphicalInstaller_functions.nsh"
!ifndef MUI_CUSTOMFUNCTION_GUIINIT
!define MUI_CUSTOMFUNCTION_GUIINIT
onGraphicalInstallerGUIInit
!else
!undef MUI_CUSTOMFUNCTION_GUIINIT
!define MUI_CUSTOMFUNCTION_GUIINIT onGUIInit
!endif
Create your own .onGUIInit function (without the dot '.'!) and call
the original onGraphicalInstallerGUIInit function.
; This function is required for
initialization of the installer
Function onGUIInit
; Extract transparency mask (.bmp
file)
SetOutPath $PLUGINSDIR
File "mask.bmp"
; Set form transparency and no
border
GraphicalInstaller::RemoveFormBorder
/NOUNLOAD $HWNDPARENT
Pop $0 # Get result of plug-in: 0 means OK, any other
value is error
GraphicalInstaller::MakeFormTransparent
/NOUNLOAD $HWNDPARENT "$PLUGINSDIR\mask.bmp"
Pop $0 # Get result of plug-in: 0 means OK, any other
value is error
; Call original Graphical Installer GUI
Init function
Call onGraphicalInstallerGUIInit
FunctionEnd
To enable skinning mechanism of Graphical Installer you need to
define symbol GRAPHICAL_INSTALLER_PROJECT_UID. See the
section File <project>.graphics.nsh for
details.
When this symbols is defined skinning mechanism is enabled. Simply
delete this symbol (or comment it out) and rebuild so the installer
will look like any regular NSIS one.
# Hash character (#) at the beginning
of line is a comment. Use it to comment the line out
# !define GRAPHICAL_INSTALLER_PROJECT_UID "Some
value"
And of course if you define this symbol (remove comment) and
rebuild the installer the skinning will work again.
You need to install Microsoft Visual C++ 2010 Redistributable
Package (x86)
Download it here (it is free) and install it on
your machine.
See this technical section how to properly create background images for NSIS.