【问题标题】:How to close a custom window after button click event - nsis如何在按钮单击事件后关闭自定义窗口 - nsis
【发布时间】:2014-02-25 12:32:07
【问题描述】:

我有以下代码:

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?

【问题讨论】:

  • 我不认为这是个好主意,但我使用 taskkill 在安装程序完成我需要的工作后杀死它

标签: nsis


【解决方案1】:

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

另一种方法是模拟单击关闭按钮:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-17
    • 1970-01-01
    • 1970-01-01
    • 2018-12-31
    • 2012-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多