Skip to content
⌘ NSIS Forum Archive

Disable "Back" button in finish page

10 posts

JoeMcC00L#

Disable "Back" button in finish page

Hey guys,

First off I'd like to thank the community for helping me out with this installer. I'm almost done, but I found one problem with my installer.

Just before the "Finish" page is displayed prompting the user to restart, I call a function that does some stuff. I only want that function to be called once, but when the user sees the finish page they have the option of pressing the "Back" button, causing the code to be executed again. Normally I would use a combination of GetDlgItem and EnableWindow to disable it, but I don't know how to have this called once the finish page is loaded. I'm using MUI, and this is what I have that's not working:

!define MUI_WELCOMEFINISHPAGE_CUSTOMFUNCTION_INIT DisableBackButton
!insertmacro MUI_PAGE_FINISH
. . .
Function DisableBackButton
     GetDlgItem $BACK $HWNDPARENT 2
     EnableWindow $BACK 0
FunctionEnd 
I have a couple work-arounds I'm considering.
1) Rewrite the Finish Page using InstallOptions, and disabling the back button
2) Make an empty function that's called just before the Finish Page. With any luck the back button will point to this empty function and it will automatically redirect to the finish page. I will test this option and post updates.

I'm sure there's some simple solution to the problem. Any help is greatly appreciated!

Thanks,
Joe
Afrow UK#
Why not put you code in an invisible install Section which is after all your other Sections?

Section
...
SectionEnd

-Stu
JoeMcC00L#
I suppose normally this would work, but I have a custom InstallOptions page displaying right after my MUI_PAGE_INSTFILES. The information that's taken from this dialogue is used in my function, so I can't really do it in a section.
Afrow UK#
I see.

This is what you want then:
!define MUI_PAGE_CUSTOMFUNCTION_SHOW DisableBackButton
!insertmacro MUI_PAGE_FINISH

-Stu
JoeMcC00L#
Thanks for the quick replies. I tested !define MUI_PAGE_CUSTOMFUNCTION_SHOW DisableBackButton and the back button was still enabled. Any other ideas?
Afrow UK#
That should work, but I guess InstallOptions is re-enabling it again. In which case, disable the button through the INI file itself:

!define MUI_PAGE_CUSTOMFUNCTION_PRE DisableBackButton
!insertmacro MUI_PAGE_FINISH

Function DisableBackButton
!insertmacro MUI_INSTALLOPTIONS_WRITE ioSpecial.ini Settings BackEnabled 0
FunctionEnd
Note: Using PRE instead of SHOW.

-Stu
JoeMcC00L#
I also tried my blank function idea, with no luck. The "back" button just pointed to my function that does stuff, not the blank one. I want to find a simpler solution than rewriting the finish page.
JoeMcC00L#
Thank you so much. This is exactly what I needed. Works like a charm. I see the information you gave me in the manual for MUI, I guess I just missread that part. Thank you for your patience with noobs like me :-).

EDIT: it took me so long to test it, I didn't see the next post about the ID. It was the !define MUI_PAGE_CUSTOMFUNCTION_PRE solution that worked. The ID solution is probably right too, I just haven't tested it yet. Thanks for the reply though.
Afrow UK#
I assumed your code was right, but it is in fact 3 and not 2.
Both codes should work fine now though.

-Stu