NSIS Experience UI Mod

I create the install sets for our company, using NSIS (Nullsoft Scriptable Install System). A while ago, we wanted to freshen up our install set, so I grabbed a copy of the NSIS Experience UI. Everybody loved the new look of the install.

However, in recent days, the request came through to be able to specify the directory to install to. The main reason for this was that people wanted to install to different drives as well, but they wanted the option to install to a specific folder as well. We have a very specific folder structure, so I built in some logic to check that the install path string was not longer than 100 characters, and I also appended the software configuration name to the path.

This presented a new issue though – if the user chose to type in a path, any path can be typed, and this path may not contain the configuration name. Or, it may have a duplicate of the configuration name.

Instead of doing some formatting with the string in code, I decided to see if there is a way to set the textbox’s read only property to true. This proved to be quite a challenge, but I eventually got hold of the XPUI.NSH file, and modified it to not allow the user to enter a path by typing it in.

In the “Function ${XPUI_UNFUNC}XPUI.dir.${XPUI_UNIQUEID}.show”, I added the following line:
EnableWindow $XPUI_TEMP1 0

This disabled the option to enter a path by typing it into the textbox. The function code looks like follows now:


Function ${XPUI_UNFUNC}XPUI.dir.${XPUI_UNIQUEID}.show


!insertmacro XPUI_HEADER_TEXT `${XPUI_${XPUI_UN}DIRECTORYPAGE_TITLE}` `${XPUI_${XPUI_UN}DIRECTORYPAGE_SUBTITLE}`


FindWindow $XPUI_TEMP1 `#32770` `` $HWNDPARENT
!insertmacro XPUI_CONTROL_SKIN $XPUI_TEMP1


!insertmacro XPUI_DEFAULT XPUI_DIRECTORYPAGE_TEXTBOX_COLOR "${XPUI_TEXT_BGCOLOR}"


GetDlgItem $XPUI_TEMP1 $XPUI_TEMP1 1019
SetCtlColors $XPUI_TEMP1 0x000000 0xFFFFFF
EnableWindow $XPUI_TEMP1 0


!insertmacro XPUI_PAGECOLOR_INIT 1001
!insertmacro XPUI_PAGECOLOR_INIT 1008
!insertmacro XPUI_PAGECOLOR_INIT 1006
!insertmacro XPUI_PAGECOLOR_INIT 1020
!insertmacro XPUI_PAGECOLOR_INIT 1023
!insertmacro XPUI_PAGECOLOR_INIT 1024


!insertmacro XPUI_PAGE_CUSTOMFUNCTION SHOW


!ifndef XPUI_NOLOCK
LockWindow off
!endif
FunctionEnd

I Hope this helps!

NSIS Path Dialog

Rudi Coetzee

Christian. Husband. Free Radical Ginger. Animal Lover. Realist.

You may also like...