Archive: Urgent: Disable Next, Back and Cancel Button issue


Urgent: Disable Next, Back and Cancel Button issue
Hi,

I would like to enquire on the following problem I am facing (the details are a bit long, would appreciate your time reading it);

I have a custom function that installs MSDE MSSQL database engine for the user. Since the process takes a certain amount of time, I need to disable the 'Next', 'Back' and 'Cancel' buttons during the installation process.

At the moment, I am using ExecWait to call the Setup.exe which would perform the installation process for MSDE. At the same time, using the ebanner plugin, I would display a banner indicating to the user that MSDE is currently being installed. Once MSDE has been installed, the banner would be removed and user would be directed to the following custom page.

Although with the banner on, if user clicks on the 'Next' or 'Cancel' button several times, user would be directed to a few skipped custom pages or a message box will be displayed confirming cancellation of the installation process. This happens once MSDE has been installed.

To prevent this, I have used one of the examples from previous NSIS forum threads to disable the 'Next', 'Back' and 'Cancel' button during installation.

The code is something like this;

/* Disable the Back, Next and Cancel buttons */
GetDlgItem $R1 $HWNDPARENT 1
EnableWindow $R1 0

GetDlgItem $R2 $HWNDPARENT 2
EnableWindow $R2 0

GetDlgItem $R3 $HWNDPARENT 3
EnableWindow $R3 0

Once Installation of MSDE is complete,

/* Re-Enable the Back, Next and Cancel buttons (after installation) */
GetDlgItem $R1 $HWNDPARENT 1
EnableWindow $R1 1

GetDlgItem $R2 $HWNDPARENT 2
EnableWindow $R2 1

GetDlgItem $R3 $HWNDPARENT 3
EnableWindow $R3 1
FunctionEnd


Based on the codes above, during MSDE installation, these 'Next’,’ Back', and 'Cancel' buttons would be grayed out (disable). Once MSDE is installed, these buttons are re-enabled and user would be automatically directed to the following custom page.

However, during installation of MSDE, even if I click on any of these buttons, I would still get a response after MSDE is installed. This would be a BIG problem for me because if the user clicks on the grayed 'Next' button several times during MSDE installation, he would be skipped a few custom pages after installation of MSDE.

Is there anyway to really make sure that these 'Next’,’ Back', and 'Cancel' buttons are disabled and even if user clicks on them, there would be no return response after the MSDE installation process?

Truly grateful for any assistance on this issue.

Thanks a million!


You could simply use HideWindow/BringToFront to hide the installer window entirely during the process, and show only banner.


You could try the ExecDos plugin with asynchronous execution.

-Stu


Hi,

Thanks Galil and Afrow for your replies.

Based on the excerpts from Galil;

"You could simply use HideWindow/BringToFront to hide the installer window entirely during the process, and show only banner."

I have tried to Hide the window, invoke the e-banner and then Bring to Front the installer window once the specific process has completed. However, when I hide the window, the Banner gets hidden as well.

The following is a sample code I have tried applying;

Function InstallMSDE

HideWindow
ebanner:show /NONUNLOAD /HALIGN=CENTRE /VALIGN=CENTRE /FIT=WIDTH "$PLUGINSDIR\MSDEBanner.gif"

SetOutPath "$TEMP\MSDE"
ExecWait 'setup.exe /qn INSTANCENAME="testsvr"' $0

BringToFront
ebanner:stop
FunctionEnd


I have even tried invoking the banner before the HideWindow command, the results are the same, both the banner and the installer window gets hidden.

I have previously considered using newadvsplash plugin, but the timer must be fixed and with MSDE installation timing not being consistent, I am not able to use the newadvsplash plugin. The AnimGif plugin did also get my consideration. However, I can't seem to get the plugin to work in my custom page function (It works in Func. OnInit)

Therefore, I feel at the moment, the e-banner seems ok for me. But based on the problem I highlighted in my initial posting and based on using the HideWindow command as an option, I can't seem to resolve my problem at the moment.

I have to simulate the ExecDos plugin as suggested by Afrow (I did read the plugin info, I am not sure if this would actually disable the Next,Back or Cancel buttons for good)


I would be extremely grateful for any support. Is there a way to Hide the Window using the HideWindow command and at the same time enable display of the e-banner while MSDE is being installed?


Thanks again!


Hi,

Based from my recent postings regarding this topic, I may have found an alternative to the disabling of the 'Next', 'Back' and 'Cancel' buttons.

At the moment, When I disable these buttons and perform some process (with a banner displayed indicating a currently ongoing process), users who click on the disabled (grayed out) 'Next', 'Back' or 'Cancel' would have the handles to these buttons saved and executed after the specific process has been executed. Hence, I were to click a disabled 'Next' 3 times, the installer would jump three pages after a specific process is complete, which is a problem here (Refer to my first posting in this topic for a full description).

A simplified sample example code is as shown below;

Page custom ShowMSDEPage InstallMSDEPage

Function ShowMSDEPage
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "MSDEPage"
!insertmacro MUI_INSTALLOPTIONS_SHOW
FunctionEnd

Function InstallMSDE
/* Disable the Next Back and Cancel buttons */
GetDlgItem $R1 $HWNDPARENT 1
EnableWindow $R1 0

GetDlgItem $R2 $HWNDPARENT 2
EnableWindow $R2 0

GetDlgItem $R3 $HWNDPARENT 3
EnableWindow $R3 0

ebanner:
SetOutPath "$TEMP/MSDE"
ExecWait 'setup.exe /qn INSTANCENAME="TESTSVR"' $0

FunctionEnd

From the codes above, during the execution of setup.exe, the Next, Back and Cancel buttons of the custom page is disabled. However, clicking on any of these disabled buttons saves and later executes these handles upon completion of the setup.exe process.

An alternative to this problem is to add a message box after the operation of setup.exe, indicating a successful MSDE Installation. In doing this, all the saved 'Next, Back / Cancel' handles are reset and the message box is displayed. Once user clicks OK to the message box, the subsequent custom page automatically loads, without executing the clicked Next, Back or Cancel handle buttons.

At the moment, having a message box after the execution a specific process prevents the handle of a disabled 'Next, Back or Cancel' buttons of instead being executed in the event user clicks on these disabled buttons.

I hope this might be helpful to others, though it is not a concrete solution.

If there are any other possible solutions, I am truly grateful for them.

Thanks


Well, I used Banner, not EBanner. Sorry to hear it didn't work out. I guess it's called EmbeddedBanner for a reason...

What about using ShowWindow instead of EnableWindow?


Hi,

Thanks for your advice,

I have tried replacing the EnableWindow command with the ShowWindow command, but the results are still the same.

On the banner, I am only aware of the EBanner plugin. I have never come accross the Banner plugin or anything of equivalent.

Is there anyway I could get the Banner plugin or any example on how to use it?

Thanks very much


Sure you can, just check in Docs\Banner. It comes with the NSIS distribution
:)

CF


Hi,

Thanks for the tip on the Docs\Banner.

Now, if use it with the HideWindow command, the banner remains until MSDE is installed, with the main Installer window hidden. It works good. I will propose this to upper management and get their feedback.

Thanks again !


I can't seem to disable the CANCEL button on a custom page.
In my custom page entry function, I have this:

!insertmacro MUI_HEADER_TEXT "Firefox Plugin installation" ""
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "iFirefox.ini"
GetDlgItem $R1 $HWNDPARENT 1 ; disable BACK button
EnableWindow $R1 0
GetDlgItem $R3 $HWNDPARENT 3 ; disable CANCEL button
EnableWindow $R3 0

This greys out the BACK button but not the CANCEL button. Any ideas what I am doing wrong?

Also, is there any way to physically remove BACK and CANCEL buttons from both Custom and Finish pages? I think things look a lot neater for the user when inactive buttons aren't even shown.

Thanks!
Fippy


Hi Fippy,


Firstly, to disable the Cancel button, it should be
GetDlgItem $R2 $HWNDPARENT 2 ; disable CANCEL button
EnableWindow $R2 0

The $HWNDPARENT 3 points to the Back button.

Secondly, I am not sure if you should use '!insertmacro MUI_INSTALLOPTIONS_DISPLAY "iFirefox.ini"' (I've tried to simulate your codes at my site but i won't work)

Try this instead;

Inside the Function .onInit, add this line of code;

Function .onInit

!insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "iFirefox.ini" "FireFoxCustom"

FunctionEnd

What the above line of code ('!insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS') does is it attaches a constant ('FireFoxCustom') to your iFirefox.ini file.

(Note, the path of 'iFirefox.ini' should be valid, in this condition, i assume its located at the same path of your installer scripts file)


Now inside your custom function, use this line of code after the '!insertmacro MUI_HEADER_TEXT' command;

!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "FireFoxCustom"

Do not use the !insertmacro MUI_INSTALLOPTIONS_DISPLAY command.

Try using your the codes;
GetDlgItem $R2 $HWNDPARENT 2 ; disable CANCEL button
EnableWindow $R2 0

to disable the Cancel button. Also remember to use the '!insertmacro MUI_INSTALLOPTIONS_SHOW' command at the end of the function to display your custom page.

Let me know if it works or not.

Hope the above helps.

PS: I am not sure nor am I aware of any feature that could physically remove the Next, Back and Cancel buttons from the custom page. Perhaps other members within the NSIS forum community might provide some advice on this.


Aha, that seems to work now!

I also had to change my exit function accordingly:

!insertmacro MUI_INSTALLOPTIONS_READ $0 "iFirefox.ini" "Field 2" "State"
to
!insertmacro MUI_INSTALLOPTIONS_READ $0 "FirefoxCustom" "Field 2" "State"

I didn't realise that you could refer to the ini files by an alias. Thanks for the help, much appreciated!

Fippy


I have similar problem.

I need start a process and in custom page disable all buttons and show animated gif until my new process runs, then I need to get exit code from this process and enable next button. But I don't understand, how can I do it?
If I start process with ExecWait in EnterPage of custom page, then I can't show my gif, and if I show gif first, then I can't start my process -> only on LeavePage, but if I click next button (but buttons are disabled)
Any ideas?

Function EnterPage
InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\EnterPage.ini"
Pop $hwnd
GetDlgItem $0 $HWNDPARENT 1 ; disable NEXT button
EnableWindow $0 0
GetDlgItem $0 $HWNDPARENT 2 ; disable CANCEL button
EnableWindow $0 0
GetDlgItem $0 $HWNDPARENT 3 ; disable BACK button
EnableWindow $0 0


SetOutPath '$PLUGINSDIR'
File progress.gif
AnimGif:: play /NOUNLOAD '$PLUGINSDIR\progress.gif'

;probably start process
;if done -> enable buttons
GetDlgItem $0 $HWNDPARENT 1
EnableWindow $0 1
GetDlgItem $0 $HWNDPARENT 2 ; enable CANCEL button
EnableWindow $0 1

InstallOptions::show ;???
FunctionEnd


Hi robotmp3!

How about HideWindow and showing one of the Banners while you're ExecWait-ing for the process?

This might be a solution!

Have a nice day!

Cheers

Bruno


Hi Bruno,

A lot of thanks for your answer!
But I don't know, how can I hide my installer (with HideWindow) and at the same time show another window? Can you give me hint?

Have nice day too :)