- NSIS Discussion
- Function request
Archive: Function request
JasonFriday13
23rd August 2007 11:31 UTC
Function request
I would like to request a function that is called when Abort is called in a section (or similar).
Why? I'll answer that now. If the user minimizes the install, and it fails, you would never know about it. But with this function, you could restore the window to let the user know. I want to use it to unload my SpiderBanner plugin and show the original window, and show "Install failed" on the DetailPrint label.
I don't have enough knowledge to implement this myself into NSIS, but if I figure it out before you guys, I will post a patch.
Comments welcome.
Anders
23rd August 2007 15:36 UTC
You could check if the window is minimized as the last instruction in your sections and then restore
Anders
23rd August 2007 15:54 UTC
!include LogicLib.nsh
!include winmessages.nsh
Section LastSection
...
System::Call 'user32::GetWindowLong(i $hwndparent,i -16)i.r0'
IntOp $0 $0 & 0x20000000
${IfThen} $0 > 0 ${|} ShowWindow $HWNDPARENT ${SW_RESTORE} ${|}
SectionEnd
JasonFriday13
24th August 2007 08:25 UTC
True, but if the installer fails for some reason, execution stops at the current command (like using abort). So you code will not be executed, leaving the window minimized. Thats what I want my abort function for, so that your code is executed if it fails.
kichik
24th August 2007 08:34 UTC
The leave function is still called. In there, you can use IfAbort.
Function leave
IfAbort 0 +2
MessageBox MB_OK abort
FunctionEnd
JasonFriday13
24th August 2007 09:08 UTC
It appears my plugin hates being destroyed in a leave function, just as much as it hates being created in a pre or show function.
My plugin deals with window placement of the installer window, and it looks like it gets stuck in a loop somewhere. My plugin only works when called inside a section.
kichik
24th August 2007 09:10 UTC
That's probably because you start it in a section, which is executed in a different thread than the leave function which is executed in the GUI thread.
JasonFriday13
24th August 2007 09:28 UTC
I have made some small adjustments in my destroy function.
I changed PostMessage into SendMessage to close the banner window, and I refreshed the global hwndparent with the hwnd passed with the destroy function. This seems to have fixed the problem with the leave function.
I'm not going to change the show function in my plugin to work in the pre function, it should only be created in a section.
Thanks guys, I used the code given by kichik, and now it works the way I want it to.