Archive: Disabling FileRequest textfield


Disabling FileRequest textfield
Hi guys

I want to disable a FileRequest textfield, while leaving the browse button available for use. Looking in testnotify.nsi, I see that to fully disable the FileRequest, you must do this:


ReadINIStr $0 "$PLUGINSDIR\test.ini" "Field 2" "State"
GetDlgItem $1 $hwnd 1204 ; PathRequest control (1200 + field 5 - 1)
EnableWindow $1 $0
GetDlgItem $1 $hwnd 1204 ; ... button (the following control)
EnableWindow $1 $0

But...what's going on here? I seem to be getting the same dialog item twice, but it's presumably once referring to the textfield, and then to the browse button.

Fair enough. I try it:

Pop $hwnd ;HWND of dialog
GetDlgItem $1 $hwnd 1202
EnableWindow $1 0
GetDlgItem $1 $hwnd 1202
EnableWindow $1 1
GetDlgItem $1 $hwnd 1203
EnableWindow $1 0
GetDlgItem $1 $hwnd 1203
EnableWindow $1 1

The FileRequests I want to modify are Fields 3 & 4, so 1202 and 1203 should do it. Do they?

No. :) It does nothing.

Any ideas? Am I missing something obvious?

Thanks!

Actually, I worked it out myself. Even though the controls are labelled "Field 3" and "Field 4", I can refer to Field 3's textfield as 1202, its button as 1203, Field 4's textfield as 1204 and it's button as 1205. Curiouser and curiouser...

So my code ends up as:


Pop $hwnd ;HWND of dialog
GetDlgItem $1 $hwnd 1202
EnableWindow $1 0
GetDlgItem $1 $hwnd 1204
EnableWindow $1 0

Sorted!

You can also read HWND and HWND2 from the INI file after it's displayed. It's a new feature added recently. It's simpler than calculating all the extra controls.