Skip to content
⌘ NSIS Forum Archive

How disable directory field on MUI_PAGE_DIRECTORY?

38 posts

Animaether#
hence why I'm using the PHP tag 😉

Must be some way - 'll have to dig around the help a bit 🙂

Edit: okay, no there isn't 😁
silly stripslashes() to remove color-coding-induced backslashes that eats regular backslashes :x
youn75#
I use this useful code :
!define InstallDirRegKey '"HKLM" "Software\${PRODUCT_PUBLISHER}\${CLIENT_NAME}\${PRODUCT_NAME}" "InstallPath"'
InstallDirRegKey ${InstallDirRegKey}

!define MUI_PAGE_CUSTOMFUNCTION_PRE DirectoryPre
!define MUI_PAGE_CUSTOMFUNCTION_SHOW DirectoryPre
!insertmacro MUI_PAGE_DIRECTORY

Function DirectoryPre
ReadRegStr $R0 ${InstallDirRegKey}
StrCmp $R0 "" FullDirectoryPage PartialDirectoryPage

PartialDirectoryPage:
FindWindow $R1 "#32770" "" $HWNDPARENT
GetDlgItem $R2 $R1 1019
EnableWindow $R2 0
GetDlgItem $R2 $R1 1001
EnableWindow $R2 0

FullDirectoryPage:
FunctionEnd
-----------------------------------------------------------
First install must write in registry 'InstallPath'.
If this 'InstallPath' exist, directory field and 'Browse' button are disabled on MUI_PAGE_DIRECTORY

Regards
From Paris,
Yves
fluidz91#
Hi,

I ve been searching and reading forum for hours without any clue why i can't get it works.

I'd like to change the Text button of the Components Page "Next >" by "Install >"

I tried so many different things i m now a little bit messed up.

#...
# Variables
Var hwnd
#...
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ComponentsShow
!insertmacro MUI_PAGE_COMPONENTS
#!define MUI_PAGE_CUSTOMFUNCTION_SHOW ComponentsShow
# Before or after !insertmacro changes nothing
#...
Function ComponentsShow
    # CHECK IF SERVER INSTALLED YET TO INSTALL SERVICE/FILES
    #MessageBox MB_OK "$(^Name) : $isInstalled$\nText : $(TEXT_INSTALL)"
    StrCmp $isInstalled "1" 0 +7
        FindWindow $hwnd "#32770" "" $HWNDPARENT
        Push $R0
        GetDlgItem $R0 $hwnd 1
       #MessageBox MB_OK "$(^Name) : $R0$\nHWND : $hwnd"
        SendMessage $R0 ${WM_SETTEXT} 0 "STR:$(TEXT_INSTALL)"
        Pop $R0
        
FunctionEnd
#...
LangString TEXT_INSTALL ${LANG_FRENCH} "&Installer >"
LangString TEXT_INSTALL ${LANG_ENGLISH} "&Install >" 
On the Components page, the next button still displays "Suivant >"
C:\NSIS\makensis.exe /VERSION
2.17

Thanks in advance.
demiller9#
The button is not a child of the sub-dialog, it is located on the main dialog. You can get the handle with
GetDlgItem $R0 $HWNDPARENT 1
But NSIS will change the button text according to whether there are other pages before the INSTFILES page. You would only need to change the text if the page(s) before INSTFILES are going to be hidden with abort.

Don
fluidz91#
Thx Don,

sorry but i don't understand the explanation (i m not english native speaker).
I tried first 'GetDlgItem $R0 $HWNDPARENT 1' without FindWindow but with same result (maybe i should retry because i ve done some other changes after).

i think i forget to say in previous post that i had a mui_page_directory i could also skip. I m gonna try to put the code in the pre function of diretory page (i lack time for the moment and a build is about 15 mn)


# Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE cluf.rtf
!insertmacro MUI_PAGE_COMPONENTS
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ComponentsShow
!define MUI_PAGE_CUSTOMFUNCTION_PRE DirectoryPre
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

...

Function ComponentsShow
# CHECK IF SERVER INSTALLED YET TO INSTALL SERVICE/FILES
;MessageBox MB_OK "$(^Name) : $isInstalled$\nText : $(TEXT_INSTALL)"
StrCmp $isInstalled "1" 0 +7
FindWindow $hwnd "#32770" "" $HWNDPARENT
Push $R0
GetDlgItem $R0 $hwnd 1
;MessageBox MB_OK "$(^Name) : $R0$\nHWND : $hwnd"
SendMessage $R0 ${WM_SETTEXT} 0 "STR:$(TEXT_INSTALL)"
Pop $R0

FunctionEnd

Function DirectoryPre
# CHECK IF SERVER INSTALLED YET TO INSTALL SERVICE/FILES
StrCmp $isInstalled "1" 0 +1
Abort # Skip page
FunctionEnd
If application is already installed i show the commonents page but next i don't want to show de directory page (that seems to work as expected).

Thx Anyway...