Archive: Disable text box and show default text


Disable text box and show default text
Hi, I'm trying to create a screen for my installer that takes user input. In doing so I need to be able to have the user select a checkbox which will disable a text box and fill it with default text, overwriting whatever was in there when the user selected the checkbox (ie the checkbox will set the textbox to a default value, but it will be visually apparent to the user). I have figured out how to make the checkbox callback so I can disable the textbox, but I don't know how to put text in the textbox at the same time. What seems to be a valid command will not work. Here's the function that the page call to show:

Function userInput
InstallOptions::dialog /NOUNLOAD $PLUGINSDIR\inputpage.ini
FunctionEnd

Here's the funtion I use to validate/callback:

Function onPageExit

push $0
push $1
push $R0
push $R1

# Read which field was changed into $R1
# Other code that does the same as the "ReadIniStr" line below
# Code: !insertmacro MUI_INSTALLOPTIONS_READ $R1 "inputpage.ini" "Settings" "State"
ReadIniStr $R1 "$PLUGINSDIR\inputpage.ini" "Settings" "State"

# Goto changestate if a field I care about gets selected
${if} $R1 == 1
goto changestate
${elseif} $R1 == 3
goto changestate
${else}
goto exit
${endif}

# Change state to disabled if enabled and bisa versa
changestate:
# Add 1 to $R1 to get the number of the field that will be disabled
intop $R2 $R1 + 1

# Get handle for field to be disabled/enabled and get
# the current state of the checkbox that is causing it
ReadIniStr $0 "$PLUGINSDIR\inputpage.ini" "Field $R2" "HWND"
ReadIniStr $1 "$PLUGINSDIR\inputpage.ini" "Field $R1" "state"

# Enable if disable, and bisa versa
StrCmp $1 1 disable enable

disable:
EnableWindow $0 0
WriteIniStr "$PLUGINSDIR\inputpage.ini" "Field $R2" "Flags" "DISABLED"
WriteIniStr "$PLUGINSDIR\inputpage.ini" "Field 2" "State" "DISABLED TEXT BOX"
pop $R1
pop $R0
pop $1
pop $0
abort

enable:
EnableWindow $0 1
WriteIniStr "$PLUGINSDIR\inputpage.ini" "Field $R2" "Flags" ""
pop $R1
pop $R0
pop $1
pop $0
abort

# Just used to exit the function when we want to leave
exit:
pop $R1
pop $R0
pop $1
pop $0

FunctionEnd


=================

I've highlighted the line that I think should work but isn't working in RED. "Field 2" in this case is a text box. Here's the code from my INI file:

; Auto-generated by EclipseNSIS InstallOptions Script Wizard
; Feb 22, 2008 8:09:23 PM
[Settings]
NumFields=4
Title=User Input Page

[Field 2]
Type=Text
Left=103
Top=41
Right=258
Bottom=54
State=
Flags=

[Field 1]
Type=CheckBox
Left=49
Top=42
Right=94
Bottom=52
Text=Default
State=0
Flags=NOTIFY

[Field 3]
Type=CheckBox
Left=49
Top=65
Right=94
Bottom=75
Text=Default
State=0
Flags=NOTIFY

[Field 4]
Type=Text
Left=103
Top=63
Right=258
Bottom=76


=================

What's especially weird is that the highlighted line of code from earlier works if I run it inside of my page-show function just before I show the INI page with InstallOptions. Here's what I mean:


Function userInput
WriteIniStr "$PLUGINSDIR\inputpage.ini" "Field 2" "State" "DISABLED TEXT BOX"
InstallOptions::dialog /NOUNLOAD $PLUGINSDIR\inputpage.ini
FunctionEnd

==============

That will set my textbox to have the text "DISABLED TEXT BOX" initially, but that line doesn't work when called inside the "onPageExit" function.

What I want to do is to be able to either put text in the textbox with the checkbox unchecked, or when the checkbox is checked fill the textbox with the text of my choice (in this case it will be a port number).

Any ideas? Any help will be much appreciated! ...Also please let me know if you need any more info or if I've been vague anywhere in this post. Thanks!


You must SendMessage with ${WM_SETTEXT}.
Check the included example testnotify.nsi, it explains everything.


Thank you! That worked perfectly!