如何使用插件或位图图像在自定义对话框中自定义NSIS复选框?
以下是NSIS installer with custom chechboxes的示例
当前复选框仅在options对话框中工作。 也许有一种方法可以使用 OnClick 事件吗?
有什么想法吗?
感谢。
答案 0 :(得分:0)
这不是本机NSIS功能,但可以使用一些自定义代码实现:
!include WinMessages.nsh
!include nsDialogs.nsh ; WS_*
ShowInstDetails nevershow
Var Task1
Var Task2
Page InstFiles "" InitTasks FreeTasks
!macro SetTaskIcon hwnd icon
SetDetailsPrint none
Push $0
!if "${icon}" != ""
File "/oname=$PluginsDir\Task${hwnd}.ico" "${icon}"
System::Call 'USER32::LoadImage(i 0, t "$PluginsDir\Task${hwnd}.ico", i ${IMAGE_ICON}, i 32, i 32, i ${LR_LOADFROMFILE})i.r0'
SendMessage ${hwnd} ${STM_SETICON} $0 0 $0
!else
SendMessage ${hwnd} ${STM_GETICON} 0 0 $0
!endif
System::Call 'USER32::DestroyIcon(i $0)'
Pop $0
SetDetailsPrint lastused
!macroend
!macro FreeTask hwnd
!insertmacro SetTaskIcon ${hwnd} ""
!macroend
!macro CreateTask outvar icon text x y
System::Store S
FindWindow $1 "#32770" "" $HWNDPARENT
System::Call 'USER32::CreateWindowEx(i 0, t "Static", t "${text}", i ${WS_CHILD}|${WS_VISIBLE}|${SS_ICON}|${SS_REALSIZEIMAGE}, i ${x}, i ${y}, i 32, i 32, i r1, i 0, i 0, i 0)i.r0'
StrCpy ${outvar} $0
!insertmacro SetTaskIcon ${outvar} "${icon}"
IntOp $2 ${x} + 32
IntOp $2 $2 + 5 ; Padding
System::Call 'USER32::CreateWindowEx(i 0, t "Static", t "${text}", i ${WS_CHILD}|${WS_VISIBLE}|${SS_CENTERIMAGE}, i $2, i ${y}, i 999, i 32, i r1, i 0, i 0, i 0)i.r0'
SendMessage $1 ${WM_GETFONT} 0 0 $2
SendMessage $0 ${WM_SETFONT} $2 1
System::Store L
!macroend
Function InitTasks
!insertmacro CreateTask $Task1 "${NSISDIR}\Contrib\Graphics\Icons\llama-grey.ico" "Foo" 40 50
!insertmacro CreateTask $Task2 "${NSISDIR}\Contrib\Graphics\Icons\llama-grey.ico" "Bar" 40 90
FunctionEnd
Function FreeTasks
!insertmacro FreeTask $Task1
!insertmacro FreeTask $Task2
FunctionEnd
Section "Foo task"
Sleep 2222 ; Pretend to do some work
!insertmacro SetTaskIcon $Task1 "${NSISDIR}\Contrib\Graphics\Icons\llama-blue.ico"
SectionEnd
Section "Bar task"
Sleep 3333 ; Pretend to do some work
!insertmacro SetTaskIcon $Task2 "${NSISDIR}\Contrib\Graphics\Icons\llama-blue.ico"
SectionEnd