How 2 set default button on uninstaller ?
Dear all.
How can I set the default button of the uninstaller to Cancel ?
Archive: How 2 set default button on uninstaller ?
How 2 set default button on uninstaller ?
Dear all.
How can I set the default button of the uninstaller to Cancel ?
For info about using custom code in a Modern UI show function, check the Modern UI Readme.
Use:
!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:
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
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 ? :-(
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 :)
What is the Show function ?
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 :)
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!)
Well:
Quote:
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.
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.
;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
Sleeping is highly overrated ;)
The focus code should come after the GetWindowLong code. It works for me that way.
more...
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.
;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
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.
10X
Quote:
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. |
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):
|