NSIS:如何在左下角添加自定义按钮并处理它';点击?

NSIS:如何在左下角添加自定义按钮并处理它';点击?,nsis,Nsis,我尝试了ButtonEvent插件,但当我运行编译后的示例时,它失败了,出现了内存访问错误。也许可以通过Windows API或其他方式使用系统插件?有人能告诉我怎么做吗 UPD:出现错误,因为我试图在unicode NSI上使用非unicode按钮。现在这个例子编译并执行OK,但当我点击TryMe按钮时,回调函数并没有被调用,也并没有发生任何事情。如何确定问题是什么?任何人都可以编译ButtonEventMUI.nsi并点击TryMe按钮吗?我下载了最新的ButtonEvent版本。使用NSI

我尝试了ButtonEvent插件,但当我运行编译后的示例时,它失败了,出现了内存访问错误。也许可以通过Windows API或其他方式使用系统插件?有人能告诉我怎么做吗


UPD:出现错误,因为我试图在unicode NSI上使用非unicode按钮。现在这个例子编译并执行OK,但当我点击TryMe按钮时,回调函数并没有被调用,也并没有发生任何事情。如何确定问题是什么?任何人都可以编译ButtonEventMUI.nsi并点击TryMe按钮吗?我下载了最新的ButtonEvent版本。使用NSIS 2.46 Unicode

系统插件无法做到这一点,因为它无法对windows进行子类化

ButtonEvent插件适合我(NSIS 2.46):


也许您可以添加更多详细信息:NSIS版本(Unicode?)和插件版本/日期…2011年有一个crashfix(),因此请确保您的插件是最新的。我使用最新的ButtonEvent Unicode和NSIS 2.46 Unicode。我更新了我的问题,谢谢你的提示。将.onGuiInit重命名为myGuiInit,然后!在脚本的顶部定义MUI_CUSTOMFUNCTION_GUIINIT myGuiInit hmm,当我单击按钮时,不会发生任何事情。。当我编译ButtonEvent示例时,也没有发生任何事情。我想问题出在我的配置上。但我甚至不知道从哪里开始搜索..尝试通过添加一些消息框来调试脚本-在GetFunctionAddress$0 onMybtClick之前的$0上。
Name BtnTest
Outfile test.exe
Installdir "$temp"
RequestExecutionLevel user
BrandingText " " ;Button covers this text
!include nsDialogs.nsh ;For WS_*

Function .onGuiInit
; You are supposed to use ChangeUI (or MUI_UI) and a modified ui file to add new buttons but this example adds the button at run-time...
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
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 "Click Me",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 $0 onmybtnclick
ButtonEvent::AddEventHandler 0x666 $0
FunctionEnd

Function onmybtnclick
MessageBox mb_ok "You clicked me!"
FunctionEnd

Page Directory
Page Instfiles

Section
SectionEnd