Archive: Callback does not reload page


Callback does not reload page
The CallBack function does not reload the page and when I check or uncheck the box it moves forward as if I clicked the next button. What am I doing wrong?
1) I call my custom page.

Page custom "PickWebsite"

2) I extract and check for a state change. Field 8 has the flag NOTIFY turned set in the custom ini file.

Function PickWebsite

!insertmacro XPUI_INSTALLOPTIONS_EXTRACT "pick_website.ini"
Call GetWebsites
!insertmacro XPUI_HEADER_TEXT "Webserver Configuration" "Choose the website and path that your installation will reside at."
!insertmacro XPUI_INSTALLOPTIONS_DISPLAY "pick_website.ini"
ReadINIStr $0 "$PLUGINSDIR\pick_website.ini" "Settings" "State"
${If} $0 == 8
Call CallBack
${EndIf}

FunctionEnd

3) Here is my call back function that if checked or unchecked i.e. 1 or 0 it will update the fields.

Function CallBack
; get value of checkbox
!insertmacro MUI_INSTALLOPTIONS_READ $R4 "$PLUGINGSDIR\pick_website.ini" "Field 8" "State"
; get the field triggered
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "$PLUGINGSDIR\pick_website.ini" "Settings" "State"

${If} $R0 == "2" ; if field 8 clicked

ReadIniStr $R3 "$PLUGINGSDIR\pick_website.ini" "Field 8" "HWND"

${If} $R4 == "1"

EnableWindow $R3 1
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 6" "Flags" "DISABLED"
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 9" "Flags" ""
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 4" "Flags" "DISABLED"
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 11" "Flags" ""
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 14" "Flags" ""
!insertmacro XPUI_HEADER_TEXT "Webserver Configuration" "Create a new website set the name, path and port."
!insertmacro XPUI_INSTALLOPTIONS_DISPLAY "pick_website.ini"

${EndIf}
${If} $R4 == "0"

EnableWindow $R3 0
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 6" "Flags" ""
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 9" "Flags" "DISABLED"
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 4" "Flags" ""
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 11" "Flags" "DISABLED"
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 14" "Flags" "DISABLED"
Call GetWebsites
!insertmacro XPUI_HEADER_TEXT "Webserver Configuration" "Choose the website and path that your installation will reside at."
!insertmacro XPUI_INSTALLOPTIONS_DISPLAY "pick_website.ini"

${EndIf}

abort ; return to page
${EndIf}
FunctionEnd


You may want to take a look at the following wiki article:
http://nsis.sourceforge.net/InstallO...of_NOTIFY_Flag


Still not sure what it is doing....
The example doesn't yet make much sense to me. Maybe you can help my by explaining what it is I should be doing.

I see three items that make very little sense to me. What does the SendMessage do GetDlgItem? The EnableWindow appears to be throwing back a 1 to $HWNDPARENT which if I am not mistaken is reloading the window?
SendMessage $2 ${WM_SETTEXT} 1 'STR:$1'
GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 1


GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 1
Enables the next button when the user has selected an item.

GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 0
Disables the next button when all items are unchecked.

Controls that they have NOTIFY flag, are captured when their state is changed. They are able to change the state of other controls regarding to the user selection.
Controls without NOTIFY flag, are captured when the next button is pressed.


Still wondering how to call the window and tell it to reload
Thanks. That was very helpful, but I am still unclear on how to update the ini and the window without moving on to the next window. I guess I am still not understanding how I make it do that. It seems to work in the example you gave me earlier "http://nsis.sourceforge.net/InstallOptions_The_Usage_of_NOTIFY_Flag" but I still don't know why and how to make mine work.


I have no idea about XPUI though, try this:

Page custom "PickWebsite" "Callback"

Function PickWebsite
;Call GetWebsites
!insertmacro XPUI_INSTALLOPTIONS_EXTRACT "pick_website.ini"
!insertmacro XPUI_HEADER_TEXT "Webserver Configuration" \
"Choose the website and path that your installation will reside at."
!insertmacro XPUI_INSTALLOPTIONS_DISPLAY "pick_website.ini"
FunctionEnd

Function CallBack
; get value of checkbox
; get the field triggered
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "$PLUGINGSDIR\pick_website.ini" "Settings" "State"

${If} $R0 == "8" ; if field 8 clicked
!insertmacro MUI_INSTALLOPTIONS_READ $R4 "$PLUGINGSDIR\pick_website.ini" "Field 8" "State"
ReadIniStr $R3 "$PLUGINGSDIR\pick_website.ini" "Field 8" "HWND"

${AndIf} $R4 == "1"

EnableWindow $R3 1
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 6" "Flags" "DISABLED"
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 9" "Flags" ""
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 4" "Flags" "DISABLED"
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 11" "Flags" ""
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 14" "Flags" ""
;!insertmacro XPUI_HEADER_TEXT "Webserver Configuration" \
"Create a new website set the name, path and port."
;!insertmacro XPUI_INSTALLOPTIONS_DISPLAY "pick_website.ini"

Abort
;${EndIf}
${ElseIf} $R4 == "0"

EnableWindow $R3 0
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 6" "Flags" ""
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 9" "Flags" "DISABLED"
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 4" "Flags" ""
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 11" "Flags" "DISABLED"
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 14" "Flags" "DISABLED"
Call GetWebsites
;!insertmacro XPUI_HEADER_TEXT "Webserver Configuration" \
"Choose the website and path that your installation will reside at."
;!insertmacro XPUI_INSTALLOPTIONS_DISPLAY "pick_website.ini"

Abort
${EndIf}

;abort ; return to page
;${EndIf}
FunctionEnd

EDIT: Added comments to red colored code, forgot to remove it :-)

Working better but still does not update...
Ok, so here is the new function. I check and un-check the boxes but the other fields stay the same. At one time using push and pop statments it seemed to work but I am hoping that what ever it is I am doing wrong I will be able to resolve soon.

Function CallBack
!insertmacro XPUI_INSTALLOPTIONS_READ $R5 "$PLUGINSDIR\pick_website.ini" "Settings" "State"
!insertmacro XPUI_INSTALLOPTIONS_READ $R4 "$PLUGINGSDIR\pick_website.ini" "Field 8" "State"
ReadIniStr $R3 "$PLUGINGSDIR\pick_website.ini" "Field 8" "HWND"
${If} $R5 = "8"
${AndIf} $R4 = "1"
EnableWindow $R3 1
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 6" "Flags" "DISABLED"
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 9" "Flags" ""
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 4" "Flags" "DISABLED"
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 11" "Flags" ""
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 14" "Flags" ""
Abort "Checkbox is set"
${ElseIf} $R4 = "0"
EnableWindow $R3 0
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 6" "Flags" ""
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 9" "Flags" "DISABLED"
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 4" "Flags" ""
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 11" "Flags" "DISABLED"
WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 14" "Flags" "DISABLED"
Abort "Checkbox not set."
${Else}
Abort "Nothing changed"
${EndIf}
FunctionEnd


I got it working...
I descided to put in messageboxes so that I could figure out what was happening. as it turns out you just call the ini and ask what the HWND number is, then set it as a varriable and use the EnableWindow function to enable or disable. e.g. EnableWindow $2(the Var containing the window ID) and a number 1 or 0. Zero meaning 'Disable' and one meaning 'Enable'. It works beautifully now. I'll probibally just comment out my popup windows now but thats it. Woo Hoo! So now I finally have my IIS installer working.

Function CallBack
ReadINIStr $R5 "$PLUGINSDIR\pick_website.ini" "Settings" "State"
ReadINIStr $R4 "$PLUGINSDIR\pick_website.ini" "Field 8" "State"
ReadINIStr $R3 "$PLUGINSDIR\pick_website.ini" "Field 8" "HWND"
ReadINIStr $2 "$PLUGINSDIR\pick_website.ini" "Field 6" "HWND"
ReadINIStr $3 "$PLUGINSDIR\pick_website.ini" "Field 9" "HWND"
ReadINIStr $4 "$PLUGINSDIR\pick_website.ini" "Field 4" "HWND"
ReadINIStr $5 "$PLUGINSDIR\pick_website.ini" "Field 11" "HWND"
ReadINIStr $6 "$PLUGINSDIR\pick_website.ini" "Field 14" "HWND"
${If} $R5 == 8
${Switch} $R4
${Case} 1
MessageBox MB_OK "Case 1 R4 = $R4"
EnableWindow $2 0
EnableWindow $3 1
EnableWindow $4 0
EnableWindow $5 1
EnableWindow $6 1
;The following are just a reminder they don't do anything.
;WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 6" "Flags" "DISABLED"
;WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 9" "Flags" ""
;WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 4" "Flags" "DISABLED"
;WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 11" "Flags" ""
;WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 14" "Flags" ""

Abort "Checkbox is set"
${Case} 0
MessageBox MB_OK "Case 0 R4 = $R4"
EnableWindow $2 1
EnableWindow $3 0
EnableWindow $4 1
EnableWindow $5 0
EnableWindow $6 0
;The following are just a reminder they don't do anything.
;WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 6" "Flags" ""
;WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 9" "Flags" "DISABLED"
;WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 4" "Flags" ""
;WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 11" "Flags" "DISABLED"
;WriteIniStr "$PLUGINGSDIR\pick_website.ini" "Field 14" "Flags" "DISABLED"
;Abort "Checkbox not set."
${Default}
;Abort "Nothing changed"
${EndSwitch}
MessageBox MB_OK "If = $R5 & R4 = $R4 & R3 = $R3"
Abort "Did Nothing"
${EndIf}
MessageBox MB_OK " Nothing was called R5 = $R5"
FunctionEnd


Well done!