- NSIS Discussion
- InstallOption / Verify / setting new text in a "Text" field.
Archive: InstallOption / Verify / setting new text in a "Text" field.
Sheik
13th February 2007 19:52 UTC
InstallOption / Verify / setting new text in a "Text" field.
Hi all,
I am using MUI (Well, UMUI), and creating a custom InstallOption page.
On this page, I have a text field (readonly), that I populate with text, based on another setting on the page.
I have set the "other" field setting to state of VERIFY, so I get a callback into my "verify" function.
This works.
However, I when I try to "update" the text field, it doesn't seem to get applied, not sure why...
I do this in the "Verify" callback:
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioA.ini" "Field 7" "State" "blah"
Then I do an "Abort" to back out back to the Custom Page again.
When it backs out, it does not contain "blah", but instead the old text that was there before...
I assume I have to send a message to the Window to redraw/update itself?
If so, How?
Thanks!
Scott
Red Wine
13th February 2007 20:03 UTC
I assume I have to send a message to the Window to redraw/update itself?
If so, How?
Right!
See the included example NSIS\Examples\InstallOptions\testnotify.nsi especially what the button clear does.
Sheik
13th February 2007 20:10 UTC
Yup.
Thats where I was getting the idea from.
They do:
ReadINIStr $1 "$PLUGINSDIR\test.ini" "Field 5" "HWND"
SendMessage $1 ${WM_SETTEXT} 0 "STR:"
Which works and completely makes sense for setting the "text" of the buttons.
But it does not seem to work for setting the actual text
inside of an Edit (text) box...
Obviously it must be a different message, I just can't seem to find the right one! =)
Scott
Red Wine
13th February 2007 20:15 UTC
The example clears the text into text fields, to set the text, you need "STR:Add_string_here".
Sheik
13th February 2007 21:35 UTC
Ya.
I seem to have more problems than just this one... =)
In my "verify" (LeaveCustom) section, I am getting very very strange results on just about everything.
Obviously I have broken something, still trying to figure out what I did... =)
Doing the following, I get a "bizarre" output on the first
Messagebox of "1: blah" (ie, it is suggesting that $1 is coming back as "blah", which is bizarre, since I don't have "blah" anywhere in my script or .ini file...)
The next MessageBox should display the HWND, but its displaying nothing at all!
Function LeaveCustom
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioA.ini" "Field 7" "State" "Old Version: $1\r\nNew Version: $2"
Strcpy $1 ""
ReadINIStr $1 "ioA.ini" "Field 7" "State"
MessageBox MB_OK "1: $1"
ReadINIStr $1 "ioA.ini" "Field 7" "HWND"
MessageBox MB_OK "2: $1"
Abort
FunctionEnd
The .ini file for field 7 isn't much:
[Field 7]
Type=Text
Left=9
Top=169
Right=131
Bottom=198
State=""
Just plain bizarre.
Red Wine
13th February 2007 21:45 UTC
lol, where the blah comes from when there isn't blah in your script?
Seriously, if you use ReadINIStr you need to add the $PLUGINSDIR e.g.
ReadINIStr $1 "$PLUGINSDIR\ioA.ini" "Field 7" "State"
Sheik
13th February 2007 22:05 UTC
> Seriously, if you use ReadINIStr you need to
> add the $PLUGINSDIR e.g.
> ReadINIStr $1 "$PLUGINSDIR\ioA.ini" "Field 7" "State"
Ah, that helped immensely!
I actually had nearly everything working, but missed the concept of needing $PLUGINSDIR !
Thanks for your help!
Scott
Red Wine
13th February 2007 22:08 UTC
This example shows the actual difference,
OutFile "Test.exe"
!include "mui.nsh"
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
Page Custom custcreate custleave
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Section
SectionEnd
Function custcreate
!insertmacro MUI_HEADER_TEXT "Custom Page" \
"Just a simple custom page"
!insertmacro MUI_INSTALLOPTIONS_WRITE "custom.ini" "field 1" "state" "some sample text"
push $0
InstallOptions::Dialog "$PLUGINSDIR\custom.ini"
pop $0
pop $0
FunctionEnd
Function custleave
!insertmacro MUI_INSTALLOPTIONS_READ $0 "custom.ini" "Settings" "state"
StrCmp $0 2 0 end
!insertmacro MUI_INSTALLOPTIONS_READ $0 "custom.ini" "field 2" "State"
StrCmp $0 0 0 +4
!insertmacro MUI_INSTALLOPTIONS_READ $0 "custom.ini" "field 1" "HWND"
SendMessage $0 ${WM_SETTEXT} 0 "STR:some sample text"
Goto +3
!insertmacro MUI_INSTALLOPTIONS_READ $0 "custom.ini" "field 1" "HWND"
SendMessage $0 ${WM_SETTEXT} 0 "STR:The text has changed now"
Abort
end:
FunctionEnd
Function .onInit
InitPluginsDir
GetTempFileName $0
Rename $0 "$PLUGINSDIR\custom.ini"
WriteINIStr "$PLUGINSDIR\custom.ini" "settings" "numfields" "2"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 1" "type" "text"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 1" "left" "10"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 1" "right" "-10"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 1" "top" "10"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 1" "bottom" "22"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 2" "type" "checkbox"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 2" "text" "I'm a checkbox"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 2" "left" "10"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 2" "right" "-10"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 2" "top" "30"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 2" "bottom" "42"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 2" "flags" "NOTIFY"
FunctionEnd
Sheik
14th February 2007 01:56 UTC
I got it working great now!
Thanks again for all your help!
Scott
Afrow UK
14th February 2007 08:43 UTC
To avoid confusion with $PLUGINSDIR when using ReadINIStr you should use the MUI_INSTALLOPTIONS_READ macro which you only give the INI file name rather than the entire path.
-Stu