Archive: activate greyed buttons at final screen


activate greyed buttons at final screen
There are three buttons at the final screen (Exit, Options, Close), two of them greyed (Exit and Options), how could I activate them and write a function for them?


I wonder, are you referring to NSIS installer?


http://nsis.sourceforge.net/ButtonEvent_plug-in

-Stu


lol, yes I am talking about NSIS :)

Afrow UK, let's see if you can help me a bit, because the example in that plugin is too complex for me.

3 is the control id of the greyed button "Options", I put this code as a function that loads the page where the button is:

 Function MyGUIInit
# Create event handler for our parent window button.
ButtonEvent::AddEventHandler /NOUNLOAD 3
FunctionEnd


and then I put this other code as a function when the page is left.
 Function ComponentsLeave
# Find out if one of our buttons was just pressed.
ButtonEvent::WhichButtonID /NOUNLOAD
Pop $R0 # Control ID of button user pressed.

and that's all, then the greyed button should do what the function ComponentsLeave says, did I understood correctly?

I found a bit of old text in the readme about the /PARENT parameter which is no longer needed... if you want to grab the Zip again at http://nsis.sf.net/File:ButtonEvent.zip

Yes that code is correct, but I wouldn't recommend using the back button though (because it belongs to the installer), but try it anyway it should still work.

$R0 in your leave function will be 3 if your button is pressed or -1 otherwise. A simple StrCmp (or ${If}) will allow you to execute NSIS code accordingly.

-Stu


this is the code I used with the previous functions:

Page InstFiles "EnterInstall" "" "ExitFunction" 


the problem is that the ExitFunction is loaded before the user can even click on a button.

Remember that I am trying to activate the buttons on the final page of the installer, which I couldn't find a page name for it, and hence I used "InstFiles".

ok, after almost four years, I attempt to do it again :P

is it possible to make clickable the button which in this screenshot is called "enrera"?

http://www.flickr.com/photos/mai9/5184179946/

because I am not sure if what the plugin ButtonEvent is made for this purpose.

Thanks


Why are you calling ExitFunction on page leave? Try not calling it.

Stu


I was trying to use it because on Feb 22 you said:

$R0 in your leave function will be 3 if your button is pressed or -1 otherwise. A simple StrCmp (or ${If}) will allow you to execute NSIS code accordingly.


I have one other question, if I want to use the button called "enrera" in the screenshot, do I have to reshack edit the UI?


Ah I see. You could try using ButtonEvent on both. Why do you need to edit the UI? If the button is already there you just need to enable it and show it (if it is hidden).

Stu


Originally posted by Afrow UK
Ah I see. You could try using ButtonEvent on both. Why do you need to edit the UI? If the button is already there you just need to enable it and show it (if it is hidden).
Ok, great, no need to edit the UI. I read it in the readme and I was wondering if I should still have to edit it.

Next.

What does it mean to "use ButtonEvent on both" which both? I don't understand what "both" are you refering to. Also, how to use ButtonEvent on them? Do you mean both buttons? The close button and the one I am interested?

I am using the default UI. So, what I have is this page with the leave function and the grey button I want to use.

Page InstFiles "EnterInstall" "" "ExitFunction" 


I am trying to read the examples, but I get lost easily.

So, what I have to do is activate the grey button and put the ButtonEvent code somewhere so I can compare $R0 on the leave function and if it's 3 then use the code I want for that button.

Now, if you can help me a little bit further... thanks

Yes try on both buttons. I understand what you are trying to do by using a leave function but you don't have to do it that way. You can just use callbacks on each button instead via ButtonEvent.

Stu


how can I use a callback on the grey button? I still don't know how to make that button active.


Get the correct control id and use that (it will be 1, 2 or 3). To make it active use EnableWindow and if necessary ShowWindow.

Stu


Ok, I am finally seeing the light :)



I made this function to see which button is pressed at the end:

Function `.onInstSuccess`
ButtonEvent::WhichButtonId
Pop $R0
MessageBox MB_OK "$R0"
FunctionEnd


But I can't get the "back" button to be active when the installer has finished. This code makes it active while installing, but it turns grey again when it's finished.


Function `obrir`
GetDlgItem $0 $HWNDPARENT 3
EnableWindow $0 1
FunctionEnd


This function is called in the instfiles page:

Page InstFiles `` `obrir` ``

I have tried and all I can suggest is you add another button (i.e. ID of 4) over the top of the Back button with Resource Hacker and only show it on the InstFiles page. For the previous and next pages you will need to hide the button again (add a Show functions for both).

I.e.

Page Components HideMyBackButton
Page InstFiles ShowMyBackButton
Page SomeOtherPage HideMyBackButton

Function HideMyBackButton
GetDlgItem $0 $HWNDPARENT 4
ShowWindow $0 ${SW_HIDE} ; WinMessages.nsh
FunctionEnd

Function ShowMyBackButton
GetDlgItem $0 $HWNDPARENT 4
ShowWindow $0 ${SW_SHOW} ; WinMessages.nsh
FunctionEnd
Stu

ok, thanks for trying. I'll see what I can do.


Originally posted by Afrow UK
I have tried and all I can suggest is you add another button (i.e. ID of 4) over the top of the Back button with Resource Hacker and only show it on the InstFiles page. For the previous and next pages you will need to hide the button again (add a Show functions for both).

I.e.[code]Page Components HideMyBackButton
Page InstFiles ShowMyBackButton
Page SomeOtherPage HideMyBackButton
Correct me if I am wrong, but with this code the "MyBackButton" is showed at the beginning of the install, not at the end (when the close button activates)

I am not using "SomeOtherPage".

If you need that behaviour then you will have to enable the button in your last section (or add another section at the end specially). As for adding in the last page, well that was just for an example.

Stu


ok thanks. I see how this goes.