zorg117
29th August 2008 21:47 UTC
Really disabling 'Next' button in a custom nsDialogs page
I am trying to figure out a way to really disable 'Next' button in a custom page created using nsDialogs.
Here is the code for disabling next button in my nsdialogs page leave function.
--------------
GetDlgItem $0 $HWNDPARENT 1
EnableWindow $0 0
--------------
On my nsDialogs page after the user enters some input and click's 'Next' button (to enter the page's leave function), I disable the 'Next' button and validate some things before enabling it again. This is necessary so that I can control the flow. Unfortunately even when the button appears disabled its not truly disabled and clicking on it multiple times runs the validation step again and again.
Note: I also tried hiding it, but since I know where it is, clicking on the seemingly non-existent button still counts as a 'Next' button click and the nsDialogs page leave function is entered.
zorg117
30th August 2008 14:54 UTC
Anyone?
LoRd_MuldeR
31st August 2008 17:17 UTC
I'm not sure if I understand your problem. If I disable a button via "GetDlgItem" + "EnableWindow" then it is REALLY disabled. However you could use an additional Var and set this Var to some value which signals whether your "validation step" should run or not. You change that Var every time you enable/disable your button. Now simply check the value of the Var in your "validation" code. In case the Var has the "wrong" value (that is: the Button should be disabled) then you simply skip the validation. Otherwise run the validation normally...
zorg117
2nd September 2008 15:17 UTC
Thank you for the response Lord. GetDlgItem+EnableWindow works on every other page but for custom pages for me. Here is how my code looks (I removed some unnecessary information but it should give you a basic idea):
#############################################################
Page custom PreReqPage CheckPreReqs
###############################################################################
Function DisableNextButton
#1 - Next, 2 - Cancel, 3 - Back
GetDlgItem $0 $HWNDPARENT 1 #1 for 'Next' button
EnableWindow $0 0
FunctionEnd
###############################################################################
Function EnableNextButton
#1 - Next, 2 - Cancel, 3 - Back
GetDlgItem $0 $HWNDPARENT 1 #1 for 'Next' button
EnableWindow $0 1
FunctionEnd
###############################################################################
Function PreReqPage
Call ValidatePreReqs
Pop $0
strcpy $PreReqPass $0
${If} $PreReqPass == "1"
abort
${EndIf}
Call HideBackButton
nsDialogs::Create /NOUNLOAD 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 100% 100% ""
Pop $Label
!insertmacro MUI_HEADER_TEXT "Prerequisites Check" "Checking Prerequisites"
nsDialogs::Show
FunctionEnd
###############################################################################
Function CheckPreReqs
Call DisableNextButton
Call ValidatePreReqs
Pop $0
strcpy $PreReqPass $0
${If} $PreReqPass == "-1"
Call EnableNextButton
abort
${EndIf}
Call EnableNextButton
FunctionEnd
###############################################################################
ready3
3rd September 2008 19:44 UTC
This is what worked for me. I use this in a function that is called based on:
${NSD_OnChange} $Text SerNoChanged
; call this to get a handle to the next button
GetDlgItem $sNext $HWNDPARENT 1 # next/install button
;then based on different criteria call:
EnableWindow $sNext 1 ; to enable
; or call
EnableWindow $sNext 0 ; to disable
Sheik
3rd September 2008 20:53 UTC
This what I use:
nsDialogs::Create /NOUNLOAD 1018
<Snip building of said custom page>
/* Disable Cancel */
GetDlgItem $0 $HWNDPARENT 2
EnableWindow $0 0
nsDialogs::Show
Sheik
3rd September 2008 20:54 UTC
Oops, mine is disabling Cancel, but the same thing applies for Next as well, just different value for the GetDlgItem.