Skip to content
⌘ NSIS Forum Archive

How I can set focus on Install button?

4 posts

anonym#

How I can set focus on Install button?

;--------------------------------
;Pages

;!insertmacro MUI_PAGE_LICENSE ""

Page custom SetCustomA LeaveCustomA
Page custom SetCustomB LeaveCustomB

!insertmacro MUI_PAGE_COMPONENTS

!define MUI_PAGE_CUSTOMFUNCTION_SHOW ShowDirectory
!insertmacro MUI_PAGE_DIRECTORY

!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

Function ShowDirectory
; [Get HWND current page of installation]
FindWindow $hwnd "#32770" "" $HWNDPARENT

; [Disable Directory field]
GetDlgItem ${TEMP} $hwnd 1019 ; IDC_DIR
EnableWindow ${TEMP} 0

; [Disable Directory GroupBox]
GetDlgItem ${TEMP} $hwnd 1020 ; IDC_SELDIRTEXT
EnableWindow ${TEMP} 0

; [Disable Browse... button]
GetDlgItem ${TEMP} $hwnd 1001 ; IDC_BROWSE
EnableWindow ${TEMP} 0

; [Disable label]
GetDlgItem ${TEMP} $hwnd 1006 ; IDC_INTROTEXT
EnableWindow ${TEMP} 0

; [Set focus on Install button]
GetDlgItem ${TEMP} $hwnd 105 ;
; TEMP - return 0
SendMessage $hwnd ${WM_NEXTDLGCTL} ${TEMP} 1 ; Set focus on Install button
FunctionEnd

NOT WORK

Thank you
kichik#
You're sending the message to the wrong window. The next button is on $HWNDPARENT, not on the inner dialog.
anonym#
Thank you

Problem is solved as follows:

; [Set focus on Install button]
; Get Item of Install button
GetDlgItem ${TEMP} $HWNDPARENT 1
; Enable Install button
EnableWindow ${TEMP} 1
; Set focus on Install button
SendMessage $HWNDPARENT ${WM_NEXTDLGCTL} ${TEMP} 1