Archive: Cannot disable whole FileRequest control


Cannot disable whole FileRequest control
  Hi,

I have problem with enabling/disabling of the GUI control. I need input control for file selection, so I've used FileRequest control. But there are also two radiobuttons and FileRequest control have to be enabled/disabled according to the radio buttons state. User wants either default file (included in the installation) or browse filesystem for his own already existing file.

My .ini file looks like this:

[Settings]
NumFields=3

[Field 1]
Type=RadioButton
Text=Default file
Left=0
Right=74
Top=4
Bottom=14
State=1
Flags=NOTIFY

[Field 2]
Type=RadioButton
Text=Already existing file
Left=0
Right=74
Top=36
Bottom=44
Flags=NOTIFY

[Field 3]
Type=FileRequest
Left=0
Right=170
Top=52
Bottom=65
Flags=DISABLED


Page function:
Function SetFileTypePage
!insertmacro INSTALLOPTIONS_DISPLAY "FileType.ini"
FunctionEnd


And my page leave function:
Function SetFileTypeLeave
Push $0
Push $1
!insertmacro INSTALLOPTIONS_READ $0 "FileType.ini" "Settings" "State"

${If} $0 == 1 ; default
; disable the FileRequest control
!insertmacro INSTALLOPTIONS_READ $1 "FileType.ini" "Field 3" "HWND"
EnableWindow $1 0
Abort
${ElseIf} $0 == 2 ; existing
; enable the FileRequest control
!insertmacro INSTALLOPTIONS_READ $1 "FileType.ini" "Field 3" "HWND"
EnableWindow $1 1
Abort
${EndIf}

Pop $1
Pop $0
FunctionEnd


But the problem is, that enabling/disabling works only for the textbox, not the button for files browsing. The button remains still disabled.
I don't know any way how to enable also the buton for files browsing. It is one FileRequest control, so I supposed that enabling will work for whole control (textbox and small button together), but not.
Any ideas please?

The answer is in the InstallOptions Readme (just above the "Header file" section): HWND2 holds the HWND of the browse button:

${If} $0 == 1    ; default

; disable the FileRequest control
!insertmacro INSTALLOPTIONS_READ $1 "FileType.ini" "Field 3" "HWND"
EnableWindow $1 0
!insertmacro INSTALLOPTIONS_READ $1 "FileType.ini" "Field 3" "HWND2"
EnableWindow $1 0
Abort
>${ElseIf} $0 == 2 ; existing
; enable the FileRequest control
!insertmacro INSTALLOPTIONS_READ $1 "FileType.ini" "Field 3" "HWND"
EnableWindow $1 1
!insertmacro INSTALLOPTIONS_READ $1 "FileType.ini" "Field 3" "HWND2"
EnableWindow $1 1
Abort
>${EndIf}

If I remember correctly the control id for the browse button is 1200 + field number so 1203 in your case. If that doesn't work try 1202 or 1204. I recommend switching to nsDialogs though which makes this kind of thing easier.

Stu


Originally posted by Afrow UK
If I remember correctly the control id for the browse button is 1200 + field number so 1203 in your case. If that doesn't work try 1202 or 1204. I recommend switching to nsDialogs though which makes this kind of thing easier.

Stu
1200 + Control ID - 1 as I can remember.

This is reason why to remove support for ini files :confused:

Yes, HWND2 solved my problem.
Thank you!!!


I've also tried

FindWindow $hwnd "#32770" "" $HWNDPARENT
GetDlgItem $1 $hwnd 1202
EnableWindow $1 0

and it works too. So yes, it's 1200 + Control ID - 1. Thank you guys!

Yes, nsDialogs could be better, but in our case it concerns several products and depends on current time possibilities. Now it's not possible, but maybe in future we will switch...