Archive: What's the secret behind disabling the Back button?


What's the secret behind disabling the Back button?
  I am using Modern UI 2.0.

When not adding a custom page between MUI_PAGE_INSTFILES and MUI_PAGE_FINISH, the [Back] button on the finish page is smartly disabled. This makes sense because once installation is done, there really is no "back". If the users wants to revert installation back, simply invoke the uninstaller.

However, when I add a custom page between MUI_PAGE_INSTFILES and MUI_PAGE_FINISH, the [Back] button on the finish page is enabled.

How does NSIS know that it "can" go back in the latter case? i.e. is this a "bug" or a feature?

If the latter, is there a hook or NSIS function that I can use to enable/disable the Back or the Next button in my scripts as well?


the show callback for a page, there you can call GetDlgItem+EnableWindow


Originally posted by Anders
the show callback for a page, there you can call GetDlgItem+EnableWindow
Thank you Anders. I am using Modern UI 2.0 so you are most likely referring to MUI_PAGE_CUSTOMFUNCTION_SHOW, right?

yes


Function myshow
GetDlgItem $0 $hwndparent 3 ;1,2 or 3
EnableWindow $0 1 ;1 or 0
FunctionEnd

...

!define MUI_PAGE_CUSTOMFUNCTION_SHOW myshow
!insertmacro MUI_PAGE_xxxx


Thanks again, Anders. After experimenting with this and successfully implementing what I needed, here are some of my insights for the benefit of others who have similar questions:

1. MUI_PAGE_CUSTOMFUNCTION_SHOW is for "standard" (or built-in) pages only (WELCOME, LICENSE, COMPONENTS, DIRECTORY, STARTMENU, INSTFILES, FINISH).

2. For custom pages, use the same code but in the page creator_function :


GetDlgItem $0 $hwndparent 2 ;1,2 or 3

EnableWindow$0 0 ;1 or 0
>
3. DlgItem 2 stands for the Cancel button. Is there a reference somewhere that tells which DlgItem number is assigned to which button?

3. yes and no, ok and cancel use the standard windows defines (IDOK,IDCANCEL) and you can find the back button in http://nsis.svn.sourceforge.net/view...23&view=markup

or you could use resource hacker to inspect the resource in a generated installer .exe or winspy++ on a running installer