Archive: blanking out the Install button


blanking out the Install button
how do i blank out the install button. i want it to appear, just faded out, and the user can't click on it until they select at least one component on MUI_PAGE_COMPONENTS

is there a code that I can use to set the install button temporarily off, then when the user clicks on one of the components (each component is in a different section)it will become active.

Thanks.


Disable/enable it with EnableWindow.

Stu


ok , i tried the following code and it removed the next button on the welcome page...

!define MUI_WELCOMEFINISHPAGE_CUSTOMFUNCTION_INIT disableInstallButton

Function disableInstallButton
GetDlgItem $1 $HWNDPARENT 1
EnableWindow $1 0
FunctionEnd

but now i want it to do the same thing, only on the components page, and this time the install button.
I have a bunch of sections on the components page.
How do I get this code to work on the MUI_PAGE_COMPONENTS?


Replace MUI_WELCOMEFINISHPAGE_CUSTOMFUNCTION_INIT with MUI_PAGE_CUSTOMFUNCTION_SHOW and place the entire line (!define ...) before !insertmacro MUI_PAGE_COMPONENTS.

As for enabling/disabling the button dynamically on section check/uncheck, you need to do this in .onSelChange and use ${If} ${SectionIsSelected} (LogicLib.nsh).

Stu


ok replacing the line and placing it before MUI_PAGE_COMPONENTS worked successfully!
The Install option is now blanked out.

The next problem is this...

I have included LogicLib at the top of my script as
!include LogicLib.nsh

However, when I add the following code to .onSelChange, which is located at the very bottom of my script, i get a compiler error message

Function .onSelChange
${If} ${SectionIsSelected}
GetDlgItem $1 $HWNDPARENT 1
EnableWindow $1 1
FunctionEnd

The error message is

!insertmacro: macro "_If" requires 4 parameter(s), passed 3!
Error in script "G:\setup.nsi" on line 398 -- aborting creation process


If I take out the code
${If} ${SectionIsSelected}
the install button appears from its blanked out state when the user clicks on a component. However, it does not return to the blanked out state when they unclick it.

Any suggestions?


${SectionIsSelected} requires a section index (the identifier you add after the section name). And you are missing the ${EndIf}. You probably want an ${Else} to reset (disable) the button when the section is not selected.

Function .onSelChange
GetDlgItem $1 $HWNDPARENT 1
${If} ${SectionIsSelected} ${mySectionId}
EnableWindow $1 1
${Else}
EnableWindow $1 0
${EndIf}
FunctionEnd

With more than one section, the logic will have to be more complex, but this is the basic idea. You will want to check that the user has selected enough sections before you enable the button, and disable the button when they don't have enough sections selected.

Don

Make sure this function goes after all sections.

I.e.

Section "A section" mySection1
SectionEnd

Section "Another section" mySection2
SectionEnd

Function .onSelChange
GetDlgItem $1 $HWNDPARENT 1
${If} ${SectionIsSelected} ${mySection1}
${OrIf} ${SectionIsSelected} ${mySection1}
EnableWindow $1 1
${Else}
EnableWindow $1 0
${EndIf}
FunctionEnd


Stu