- NSIS Discussion
- Altering Cancel Button behaviour (and/or label)
Archive: Altering Cancel Button behaviour (and/or label)
RobGrant
4th January 2005 11:17 UTC
Altering Cancel Button behaviour (and/or label)
Happy new year guys!
I need to alter a Cancel button label (to say "Skip" instead) and obviously get it to simply move on to the next page instead of halting the install process.
I've read about mysterious things such as $HWNDPARENT, FindWindow and SendMessage, all with rather sparse documentation. Can anyone point me at full documentation, or provide documentation within this thread for me and others who will no doubt struggle with this topic?
Thanks guys!
Rob
RobGrant
4th January 2005 12:53 UTC
Done the changing the label bit, here's the code:
Push $0
GetDlgItem $0 $HWNDPARENT 2
SendMessage $0 ${WM_SETTEXT} 0 "STR:Skip"
Pop $0
The cancel button is marked as 2 in GetDlgItem, that's where that comes from. The rest should be pretty self-explanatory/obvious when you've seen the docs.
Afrow UK
4th January 2005 13:45 UTC
To find dialogue item id's you can use Resource Hacker.
What do you mean by moving the cancel button? Do you want a cancel button on the InstFiles page?
-Stu
RobGrant
4th January 2005 14:28 UTC
Hah! sorry. I mean I want the behaviour of the Cancel button to change, so that instead of cancelling the install, the user is moved onto the next page (i.e. skipping the current page).
Even help with simply removing the prompt (are you sure you want to cancel" or whatever) would be helpful, at least then I could play with MUI_INSTALLOPTIONS_DISPLAY_RETURN stuff.
Thanks
Rob
RobGrant
4th January 2005 15:37 UTC
Bump! I'd love to fix this by the end of the day if poss guys...:) (45mins to go)
kichik
4th January 2005 16:05 UTC
To the best of my knowledge, this is not possible without changing the source code or writing a plug-in that will override the handling of IDCANCEL. Once IDCANCEL is caught, the quit flag is set and NSIS quits immediately after the custom page function returns. There is no way to unset the quit flag.
RobGrant
4th January 2005 16:09 UTC
Aah. Ok, thanks for that, I'll stop searching :) I found a thread where you said something similar but it was from ages ago so I thought things might have changed.
Cheers!
Rob
deguix
5th January 2005 00:48 UTC
There is a way. I created a function that goes to another page on the installer relatively from the current page. I played with it and the callback funcion ".onUserAbort" to try to get the results you expect. What's incredible is that I got it working all right!!!
1) You need to copy this function code into your script.
2) If you want to skip a page for ALL installer pages, copy this below:
Function .onUserAbort
StrCpy $R9 1 ;It uses the variable $R9
Call RelGotoPage
Abort
FunctionEnd
OR
If you only want only ONE page to skip another, you need to:
- use a variable to hold the page index:
- inside the PreFunction of every page.
- before InstallOptions plugin first call inside every custom page main function.
- compare this variable inside the callback function.
This is an example:
Page custom CustomPage
Page components Components_PreFunction
Page directory Directory_PreFunction
Function CustomPage
StrCpy $R8 1 ;This is the first page
InstallOptions::dialog "C:\Dir\Temp.ini"
Pop $0
FunctionEnd
Function Components_PreFunction
StrCpy $R8 2 ;This is the second page
FunctionEnd
Function Directory_PreFunction
StrCpy $R8 3 ;This is the third page
FunctionEnd
Function .onUserAbort
StrCmp $R8 1 0 End ;Compare the variable with the
;page index of your choice
StrCpy $R9 1
Call RelGotoPage
Abort
End:
FunctionEnd
(I based the function "Goto a NSIS Page" from a code inside "io.cpp" that can be found inside "NSIS\Contrib\InstallOptions" folder)
RobGrant
5th January 2005 08:54 UTC
Wow this is fantastic thanks! Question tho - it says it can already see an .onUserAbort function; is this because I'm using the MUI or am I just stupid or what? :)
Cheers
Rob
P.S. thanks again amazing!
RobGrant
5th January 2005 10:02 UTC
Oooh, MUI_CUSTOMFUNCTION_ABORT, right?
deguix
5th January 2005 11:20 UTC
Yeah. I put this information on the Archive page.