Skip to content
⌘ NSIS Forum Archive

InstallOptions Custom Page Write to Field

16 posts

lievencardoen#

InstallOptions Custom Page Write to Field

ReadINIStr $0 "$PLUGINSDIR\directoryRequest.ini" "Field 2" "State"

With this piece of code I read the content of a textfield in a custom page. But is there a way to write something in that field???

thx, Lieven cardoen
lievencardoen#
I tried doing this, but nothing changes in my DirRequest Field

WriteINIStr "$PLUGINSDIR\directoryRequest.ini" "Field 2" "State" $7
IfErrors 0 +2
MessageBox MB_OK "Error writing to ini"
FlushINI "$PLUGINSDIR\directoryRequest.ini"

Also, no error is given.
Red Wine#
WriteIniStr "$PLUGINSDIR\directoryRequest.ini" "Field 2" "State" "your record"

Using WriteIniStr you may write/update manually every Ini field.

Check included InstallOptions examples :-)
lievencardoen#
Thx, but it doesn't seem to work.

What does this code do :

FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R1 $R0 1200
SendMessage $R1 ${WM_SETTEXT} 1 "STR:Browse"


Lieven
Red Wine#
Setting the text for the specified control (1200), needs !include WinMessages.nsh.

Just try to 'play' a little with IO examples and you'll get 'em all. :-)
lievencardoen#
Could it be that you need to use Writeinistr before Custom Page is shown?

I need to change the state of DirRequest when Custom Page is shown.

Lieven
lievencardoen#
Well,

writeinistr does seem to work, because when i do a readinistr right after, the state has changed. But visually nothing changes...
lievencardoen#
It's kind of Chinese to me. I don't understand why writeinistr changes the state, but visually nothing changes...
lievencardoen#
If I put
WriteINIStr "$PLUGINSDIR\directoryRequest.ini" "Field 2" "State" "Testing"
in the .onInit it does work...
lievencardoen#
Thx Red Wine for the replies, but I think I'm missing something important.

ps : All these examples you are talking about, where can I find them. In my NSIS folder, there aren't many examples...
Red Wine#
Wherever is your NSIS Installation e.g. C:\Program Files\NSIS\Examples\InstallOptions.

There are 4 IO examples, try to 'play' a little with them, the one according to your request is 'testnotify.nsi' :-)
lievencardoen#
I've looked at it, and it doesn't solve my problem, because in all of the examples a certain value in a ini is set before the custom page is shown.
My problem is that I change a value when custom page is allready shown, and this doesn't seem to work...

Lieven
lievencardoen#
Ok, i found it!!!

ReadINIStr $1 "$PLUGINSDIR\directoryRequest.ini" "Field 2" "HWND"
SendMessage $1 ${WM_SETTEXT} 0 "STR:$drive\"

Red Wine, thx for your time!!! Cheers!