Skip to content
⌘ NSIS Forum Archive

Show a nsdialog when user close main GUI

4 posts

meoit#

Show a nsdialog when user close main GUI

I am use MUI2.

And trying to custome abort message, so, I want show a nsdialog when user closing main GUI.

I tried MUI_PAGE_FUNCTION_ABORTWARNING, MUI_CUSTOMFUNCTION_ABORT
but failed, it is close main GUI.


Function myAbort
System::Call 'user32::SetWindowPos(i$HWNDPARENT,i,i,i,i 640,i 480,i 0x16)' ; Resize outer dialog
GD::Create 1044
;Pop $0
;System::Call 'user32::MoveWindow(i$0,i0,i0,i 600,i 200,i0)' ; Resize inner (nsDialogs) page
${NSD_CreateLabel} 0 10u 100% 10u "Hello, welcome to nsDialogs!"
Pop $0
SetCtlColors $0 0xffffff 0xff2255
GD::Show
FunctionEnd
r2du-soft#
Try This:

!include "MUI2.nsh"
!include "X64.nsh"
!include "nsdialogs.nsh"

!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES

Var QuitValue

Function .onUserAbort

${IF} $QuitValue S== ""
IntOp $QuitValue $QuitValue + 1
System::Call 'user32::SetWindowPos(i$HWNDPARENT,i,i,i,i 640,i 480,i 0x16)' ; Resize outer dialog

nsDialogs::Create 1018
Pop $0
${If} $0 == error
		Call Aborting
${EndIf}
${NSD_CreateLabel} 0 10u 100% 10u "Hello, welcome to nsDialogs!"
Pop $0
SetCtlColors $0 0xffffff 0xff2255
nsDialogs::Show

${Else}
	Goto End
${EndIF}

End:
FunctionEnd


Section "Main"
SectionEnd
meoit#
Thanks r2du-soft

Could you explicate in line code:

${IF} $QuitValue S== ""
IntOp $QuitValue $QuitValue + 1
r2du-soft#
Originally Posted by meoit View Post
Thanks r2du-soft

Could you explicate in line code:

${IF} $QuitValue S== ""
IntOp $QuitValue $QuitValue + 1
his code:

This piece of code:
${IF} $QuitValue S== ""
IntOp $QuitValue $QuitValue + 1

${Else}
	Goto End
${EndIF}

End:
Added To stop Regiment.
if you remove that, the second time when user click on cancel, application hangs Because the nsDialogs::Create 1018 it was already made once.
This piece of code is to prevent the problem from occurring....
To understand the cause: remove remove this piece of code and testing 😉