Old 1st June 2011, 16:38   #1
zbynour
Junior Member
 
Join Date: Feb 2011
Posts: 10
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:

code:
[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:
code:
Function SetFileTypePage
!insertmacro INSTALLOPTIONS_DISPLAY "FileType.ini"
FunctionEnd



And my page leave function:
code:
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?
zbynour is offline   Reply With Quote
Old 1st June 2011, 18:22   #2
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
The answer is in the InstallOptions Readme (just above the "Header file" section): HWND2 holds the HWND of the browse button:
PHP Code:
${If} $== 1    ; default
    ; 
disable the FileRequest control
    
!insertmacro INSTALLOPTIONS_READ $"FileType.ini" "Field 3" "HWND"
    
EnableWindow $1 0
    
!insertmacro INSTALLOPTIONS_READ $"FileType.ini" "Field 3" "HWND2"
    
EnableWindow $1 0
    Abort
${ElseIf} $== 2    existing
    
enable the FileRequest control
    
!insertmacro INSTALLOPTIONS_READ $"FileType.ini" "Field 3" "HWND"
    
EnableWindow $1 1
    
!insertmacro INSTALLOPTIONS_READ $"FileType.ini" "Field 3" "HWND2"
    
EnableWindow $1 1
    Abort
${EndIf} 
pengyou is offline   Reply With Quote
Old 2nd June 2011, 07:06   #3
zbynour
Junior Member
 
Join Date: Feb 2011
Posts: 10
Yes, HWND2 solved my problem.
Thank you!!!
zbynour is offline   Reply With Quote
Old 2nd June 2011, 07:22   #4
zbynour
Junior Member
 
Join Date: Feb 2011
Posts: 10
I've also tried
code:
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...
zbynour is offline   Reply With Quote
Old 1st June 2011, 18:22   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 2nd June 2011, 06:33   #6
T.Slappy
Major Dude
 
T.Slappy's Avatar
 
Join Date: Jan 2006
Location: Slovakia
Posts: 562
Send a message via ICQ to T.Slappy
Quote:
Originally Posted by Afrow UK View Post
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

Cool looking installers with custom design: www.graphical-installer.com
Create Setup Pages easily: www.install-designer.com
Build installers in Visual Studio 2005-2022: www.visual-installer.com
or RAD Studio 2009 - 11 Alexandria: www.rad-installer.com
T.Slappy is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump