Archive: Callback functions to individual widgets?


Callback functions to individual widgets?
I have a custom page that looks like:

--------------------------------------------------------
Software Audit

[x] Python C:\Python24\Python.exe
[ ] Perl C:\PROGRA~1\Perl\bin\perl.exe
[ ] LaTeX
... Several more components

Select an item for more details or to download a missing package.
--------------------------------------------------------

I've been asked to try to simplify things by showing the paths to the .exe files only if the user asks for them. I imagine adding a checkbox: [ ] Show location
so that the view changes on the fly to

--------------------------------------------------------
Software Audit
[ ] Show location
[x] Python Installed already
[ ] Perl Installed already
[ ] LaTeX
...
--------------------------------------------------------

Is such a thing possible? I guess I mean, "Can I connect a callback function to a checkbox?"

Also, are there any docs for the syntax of a .ini file? I can't find them in the NSIS help pages.

Regards,
Angus


Yes it should be possible, if you use the Flag=NOTIFY attribute. Then on the Page Leave function, you need to read from [Settings]=>State (which will be the field number) then call Abort when you're done with validation.

If that doesn't work, then just do all validation when user clicks Next button, then go back to page if things aren't right (perhaps with MessageBox).

-Stu


Perfect!
Angus


Hmmmmmmmm. Not quite perfect. I can call the function where I specify the labels:

StrCpy $0 "..."
!insertmacro MUI_INSTALLOPTIONS_WRITE "software_audit.ini" "Field 3" "Text" $0

But the view of this label isn't being updated. Is there a MUI_INSTALLOPTIONS_FLUSH or such like?

Angus


You need to manipulate the dialog with SendMessage instead (as the dialog at that time is in memory, no longer in INI file).

Example:

!include WinMessages.nsh

Var HWND

Function show
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "io_file.ini"
Pop $HWND ;HWND of dialog
!insertmacro MUI_INSTALLOPTIONS_SHOW
FunctionEnd

Function leave
GetDlgItem $R0 $HWND 1200 ;1200 + Field number - 1
CreateFont $R1 "Tahoma" 10 700
SendMessage $R0 ${WM_SETFONT} $R0 0
FunctionEnd


-Stu

Thanks, Stu. I've almost got it working, but the code below ends up clearing the text, not showing the new stuff. That's despite the fact that the MessageBox does show the right stuff:

${if} $SAVisible == "1"
GetDlgItem $2 $DialogHandle 1207
MessageBox MB_OK "Item: $2$\r$\nText: $0"
SendMessage $2 ${WM_SETTEXT} "$0" 0
${else}
!insertmacro MUI_INSTALLOPTIONS_WRITE "software_audit.ini" "Field 8" "Text" $0
${endif}

The code looks reasonable to me, so I'm a little stumped...
Angus


Use:

 SendMessage $2 ${WM_SETTEXT} 0 "STR:$0" 
Notice the "STR:" prefix and the parameter order.

The syntax of the INI file is documented in the documentation of the InstallOptions plug-in. In version 2.07, it's in Docs\InstallOptions. In versions prior to that it's in Contrib\InstallOptions.

Woooooo! It works! Many thanks to you both.
Angus