2013-02-28 38 views
0

有下面的代码:如何按钮单击事件后关闭自定义窗口 - 我NSIS

Function fnc_custom_page 
GetDlgItem $0 $HWNDPARENT 2 ; Find cancel button 
System::Call *(i,i,i,i)i.r1 
System::Call 'USER32::GetWindowRect(ir0,ir1)' 
System::Call *$1(i.r2,i.r3,i.r4,i.r5) 
IntOp $5 $5 - $3 ;height 
IntOp $4 $4 - $2 ;width 
IntOp $4 $4 + 50 
System::Call 'USER32::ScreenToClient(i$HWNDPARENT,ir1)' 
System::Call *$1(i.r2,i.r3) 
System::Free $1 
IntOp $2 $2 - $4 ;x 
IntOp $2 $2 - 8 ;x+padding 
System::Call 'USER32::CreateWindowEx(i0,t "Button",t "Open tch",i${WS_CHILD}|${WS_VISIBLE}|${WS_TABSTOP},ir2,ir3,ir4,ir5,i $HWNDPARENT,i 0x666,i0,i0)i.r0' 
SendMessage $HWNDPARENT ${WM_GETFONT} 0 0 $1 
SendMessage $0 ${WM_SETFONT} $1 1 
GetFunctionAddress $R0 fnc_tch 
ButtonEvent::AddEventHandler 0x666 $R0 

nsDialogs::Show 
FunctionEnd 

Function fnc_tch 
Exec "$INSTDIT\tch.exe" 
Abort 
FunctionEnd 

我只有一个网页,我不想表现出任何别的东西。如果我点击打开tch,tch.exe应该运行并且安装程序应该退出;但我无法让安装程序退出。 请输入任何内容。

来源为上面的代码:NSIS: How to add custom button to left bottom corner and handle it's click?

+0

我不认为这是好主意,但我已经使用的taskkill杀安装已经完成,我需要 – Vivek 2013-02-28 21:58:19

回答

2

大多数时候,你可以使用Quit但与插件相关的回调函数不处理它(退出标志不是插件API的一部分)。

另一种方法是效仿上的关闭按钮点击:

!include WinMessages.nsh 
SendMessage $HwndParent ${WM_CLOSE} 0 0 
+0

退出作业后也没有工作!:( – Vivek 2013-03-01 16:11:35

相关问题