Dear all.
How can I set the default button of the uninstaller to Cancel ?
How 2 set default button on uninstaller ?
18 posts
For info about using custom code in a Modern UI show function, check the Modern UI Readme.
Use:
in the show function of the uninstall confirmation page. If the borders of the buttons don't come out right you'll have to set the styles of them too using SetWindowLong and GetWindowLong.!define IDCANCEL 2
!define DM_SETDEFID 0x401
GetDlgItem $0 $HWNDPARENT ${IDCANCEL}
SendMessage $HWNDPARENT ${DM_SETDEFID} ${IDCANCEL} 0
System::Call "User32::SetFocus(i) i ($0) .r0"
more...
10X 4 the quick response,
I try this:
(it does not exist...)
I also try 2 comment the un.onInit and it still dont work
any idea ?
10X 4 the quick response,
I try this:
But I get a strange error: Function named "un.onGUIInit" already exists.Function un.onGUIInit
!define IDCANCEL 2
!define DM_SETDEFID 0x401
GetDlgItem $0 $HWNDPARENT ${IDCANCEL}
SendMessage $HWNDPARENT ${DM_SETDEFID} ${IDCANCEL} 0
System::Call "User32::SetFocus(i) i ($0) .r0"
FunctionEnd
(it does not exist...)
I also try 2 comment the un.onInit and it still dont work
any idea ?
You're probably using the MUI which uses un.onGUIInit. You should use a MUI define to add un.onGUIInit code. But that won't help you anyway because you need to put this code in the show function of the confirmation page of the uninstaller.
:-)
Only now I saw that U R from Holly Land 2 :-)
what would U suggest me 2 do ?
Should I change the dialog ? :-(
Only now I saw that U R from Holly Land 2 :-)
what would U suggest me 2 do ?
Should I change the dialog ? :-(
No, you shouldn't change the dialog, that won't work because NSIS sets the default button programmatically. You should put that code in the show function of the confirmation page.
Yes, I'm from Israel too 🙂
Yes, I'm from Israel too 🙂
What is the Show function ?
I could'nt figure out what is the Show function,
will U tell me some more ?
Originally posted by kichik
No, you shouldn't change the dialog, that won't work because NSIS sets the default button programmatically. You should put that code in the show function of the confirmation page.
Yes, I'm from Israel too 🙂
I could'nt figure out what is the Show function,
will U tell me some more ?
It's a callback function that is called after the page is created and right before it's shown. Without the MUI it's the third parameter to the Page command (Page type pre_func show_func) and with the MUI you define MUI_UNCUSTOMFUNCTION_CONFIRM_SHOW (for our case. for other cases the define name is different) as your show function name.
Works!
Hay, Thanks a lot, it works,
(not perfectly)
The focus does go to the cancel button,
if you just hit enter it will cancel,
but for some reason the uninstall button is still marked,
only if I click the cancel button this "mark" goes to cancel button
do U know how to set it too ?
(anyway - it's been great help - 10X!)
Hay, Thanks a lot, it works,
(not perfectly)
The focus does go to the cancel button,
if you just hit enter it will cancel,
but for some reason the uninstall button is still marked,
only if I click the cancel button this "mark" goes to cancel button
do U know how to set it too ?
(anyway - it's been great help - 10X!)
Well:
If the borders of the buttons don't come out right you'll have to set the styles of them too using SetWindowLong and GetWindowLong.The code for it is (use in the same show function before the other code):
!define GWL_STYLE -16
!define BS_DEFPUSHBUTTON 1
GetDlgItem $0 $HWNDPARENT 1
System::Call "user32::GetWindowLongA(i $0, i ${GWL_STYLE}) i .s"
Pop $1
IntOp $2 ${BS_DEFPUSHBUTTON} ~
IntOp $1 $1 & $2
System::Call "user32::SetWindowLongA(i $0, i ${GWL_STYLE}, i $1) .s"
Pop $1
Kichik, 10X so much 4 your help,
I was not able 2 figure out what are the parameters for GetWindowLongA()
(what is i, what is .s ?)
Anyway, my function (below) does get focus on cancel but not "mark" him
if U did not have enough of this matter I love 2 use some more help
Again, 10X 4 your time.
I was not able 2 figure out what are the parameters for GetWindowLongA()
(what is i, what is .s ?)
Anyway, my function (below) does get focus on cancel but not "mark" him
if U did not have enough of this matter I love 2 use some more help
Again, 10X 4 your time.
Function un.GuiInit
;http://forums.winamp.com/showthread....362#post985362
GetDlgItem $0 $HWNDPARENT ${IDCANCEL}
SendMessage $HWNDPARENT ${DM_SETDEFID} ${IDCANCEL} 0
System::Call "User32::SetFocus(i) i ($0) .r0"
GetDlgItem $0 $HWNDPARENT 1
System::Call "user32::GetWindowLongA(i $0, i ${GWL_STYLE}) i .s"
Pop $1
IntOp $2 ${BS_DEFPUSHBUTTON} ~
IntOp $1 $1 & $2
System::Call "user32::SetWindowLongA(i $0, i ${GWL_STYLE}, i $1) .s"
Pop $1
FunctionEnd
Is that code in the show callback function or is it in the un.onGUIInit callback? It should be in the show callback function.
Originally posted by kichikDon't U ever sleep :-)
Is that code in the show callback function or is it in the un.onGUIInit callback? It should be in the show callback function.
I put this code on top
;Override UnInstall GuiInit function (set focus on Cancel button)
!define MUI_UNCUSTOMFUNCTION_CONFIRM_SHOW un.GuiInit
;Allow setting the focus on Cancel button
!define DM_SETDEFID 0x401
!define IDCANCEL 2
;Allow setting the button style (after got focus)
!define GWL_STYLE -16
!define BS_DEFPUSHBUTTON 1
(so I guess un.GuiInit is the show function, is it ?)
Sleeping is highly overrated 😉
The focus code should come after the GetWindowLong code. It works for me that way.
The focus code should come after the GetWindowLong code. It works for me that way.
more...
(Cancel does get the focus but not being "marked")
This is the exact code I use:
it would be great if U could paste the code U use for that
(Set style + Focus)
10X
Originally posted by kichikMaybe I got some character wrong,
Sleeping is highly overrated 😉
The focus code should come after the GetWindowLong code. It works for me that way.
(Cancel does get the focus but not being "marked")
This is the exact code I use:
;Override UnInstall GuiInit function (set focus on Cancel button)
!define MUI_UNCUSTOMFUNCTION_CONFIRM_SHOW un.GuiInit
;Allow setting the focus on Cancel button
!define DM_SETDEFID 0x401
!define IDCANCEL 2
;Allow setting the button style
!define GWL_STYLE -16
!define BS_DEFPUSHBUTTON 1
Function un.GuiInit
;http://forums.winamp.com/showthread....362#post985362
GetDlgItem $0 $HWNDPARENT 1
System::Call "user32::GetWindowLongA(i $0, i ${GWL_STYLE}) i .s"
Pop $1
IntOp $2 ${BS_DEFPUSHBUTTON} ~
IntOp $1 $1 & $2
System::Call "user32::SetWindowLongA(i $0, i ${GWL_STYLE}, i $1) .s"
Pop $1
GetDlgItem $0 $HWNDPARENT ${IDCANCEL}
SendMessage $HWNDPARENT ${DM_SETDEFID} ${IDCANCEL} 0
System::Call "User32::SetFocus(i) i ($0) .r0"
FunctionEnd
it would be great if U could paste the code U use for that
(Set style + Focus)
10X
Ah, using XPStyle on shows it... =/
Looking at the code again, you can't set the focus on the right button. NSIS sets it after the show function and the leave function is already too late 🙁
I'm sorry for the confusion.
Looking at the code again, you can't set the focus on the right button. NSIS sets it after the show function and the leave function is already too late 🙁
I'm sorry for the confusion.
10X
Nevermind,
I did accomplish my main goal - set focus on Cancel,
so 10X 4 all the great tips.
Originally posted by kichik
Ah, using XPStyle on shows it... =/
Looking at the code again, you can't set the focus on the right button. NSIS sets it after the show function and the leave function is already too late 🙁
I'm sorry for the confusion.
Nevermind,
I did accomplish my main goal - set focus on Cancel,
so 10X 4 all the great tips.