2013-02-28 92 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

相關問題