ButtonEvent为NSIS自定义按钮提供增加响应函数代码功能

/*
 ButtonEvent为NSIS自定义按钮提供增加响应函数代码功能
 *可以使用resourcehacker对对话框资源进行更改,ButtonEvent插件不提供动态插入按钮功能,
 资源UI在NSIS安装目录下的ContribUIs里面,MUI:modern.exe,Classic:default.exe.
 *你可以使用如下语句进行引用:
 *(MUI/MUI2)!define MUI_UI ui_file
 *(Classic)ChangeUI all ui_file
 *在添加按钮资源的时候,尽量将控件的ID予以命名在nsis中自定义控件是从1200开始的,如果不对控件进行命名,
 在对控件进行处理的时候比较麻烦,比如难以知道其句柄值.
 ButtonEvent::AddEventHandler: 为控件增加函数响应
 */
 !AddPluginDir "."
 !include "MUI2.nsh"
 OutFile "ButtonEvent.exe"
 !define MUI_CUSTOMFUNCTION_GUIINIT onGUIInit
 #!define MUI_FINISHPAGE_NOAUTOCLOSE
 #!define MUI_UI `modern_modified.exe`
 !define MUI_PAGE_CUSTOMFUNCTION_SHOW WelcomeShow
 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE WelcomeLeave
 !insertmacro MUI_PAGE_WELCOME
 !insertmacro MUI_PAGE_DIRECTORY
 !insertmacro MUI_LANGUAGE English
 #必须定义在MUI之后,否则会被覆盖,或直接定义MUI_UI亦可
 ChangeUI all "modern_modified.exe"
 !define IDC_BUTTON_TRYME 1190
 Function onGUIInit
 GetFunctionAddress $R0 Add_Button1_Func
 ButtonEvent::AddEventHandler ${IDC_BUTTON_TRYME} $R0
 FunctionEnd
 Function Add_Button1_Func
 MessageBox MB_OK|MB_ICONEXCLAMATION "永恒心锁"
 Abort
 FunctionEnd
 Function WelcomeShow
 GetDlgItem $0 $HWNDPARENT ${IDC_BUTTON_TRYME}
 SendMessage $0 ${WM_SETTEXT} 0 "STR:永恒心锁"
 FunctionEnd
 Function WelcomeLeave
 GetFunctionAddress $R0 Add_Button1_Func
 ButtonEvent::AddEventHandler ${IDC_BUTTON_TRYME} $R0
 FunctionEnd
 Section "永恒心锁"
 SectionEnd
© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容