簡體   English   中英

如何在自定義對話框中自定義NSIS復選框?

[英]How to customize NSIS checkbox in custom dialog?

如何使用插件或位圖圖像在自定義對話框中自定義NSIS復選框?

這是帶有自定義復選框NSIS安裝程序的示例 在此處輸入圖片說明

當前復選框僅在選項對話框中起作用。 也許有一種方法可以通過使用OnClick事件來做到這一點?

任何想法?

謝謝。

這不是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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM