ilce
ilce

Reputation: 1046

NSIS - How to make "Install" button always to be enabled

I removed info for available space but the install button is still disabled when there is no enough space for the installation itself. I want to make "install" button always enabled. I tried this but with no success:

Function .onInit
  Call enableInstallBtn
FunctionEnd

Function enableInstallBtn
    GetDlgItem $0 $hWndParent 1 ; Get button handle
    EnableWindow $0 1
FunctionEnd

enter image description here

Upvotes: 1

Views: 210

Answers (1)

Anders
Anders

Reputation: 101774

.onInit is executed before the UI exists. The documentation tells you to set dirverify to leave:

RequestExecutionLevel User
InstallDir $temp

!include MUI2.nsh
!include LogicLib.nsh

!define MUI_DIRECTORYPAGE_VERIFYONLEAVE
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE verifydir
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"

Function verifydir
GetInstDirError $0
${If} $0 = 1
  MessageBox MB_IconStop "Invalid installation directory!"
  Abort
${EndIf}
FunctionEnd

Section
AddSize 999999999 ; I'm huge
SectionEnd

Upvotes: 1

Related Questions