我在Nsis中编写脚本,我需要在我的许可页面上选择单选按钮以及另一个确认的复选框。 是否可以这样做,因为如果我尝试插入两个更高优先级的复选框,我会丢失单选按钮。 我希望只修改许可页面而不创建自定义页面!
感谢您的帮助!
答案 0 :(得分:7)
使用修改后的(Resource Hacker)许可证页面并将其应用于ChangeUI(或MUI_UI),然后使用SendMessage在运行时获取状态。
使用系统插件在运行时创建一个新复选框:
!include nsdialogs.nsh
!include MUI2.nsh
!define MUI_LICENSEPAGE_RADIOBUTTONS
!define MUI_PAGE_CUSTOMFUNCTION_SHOW licshow
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE licleave
!insertmacro MUI_PAGE_LICENSE "${__FILE__}"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Function licshow
System::Call '*(i,i,i,i)i.r1'
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $2 $0 0x40A
System::Call 'USER32::GetWindowRect(ir2,ir1)'
System::Call 'USER32::MapWindowPoints(i0,ir0,ir1,i1)'
System::Call '*$1(i.r6,i.r7)'
System::Call 'USER32::GetClientRect(ir2,ir1)'
System::Call '*$1(i,i,i.r8,i.r9)'
IntOp $9 $9 + 3 ;padding
IntOp $7 $7 - $9
GetDlgItem $2 $0 0x3EE
System::Call 'USER32::GetClientRect(ir2,ir1)'
System::Call '*$1(i,i,i.r3,i.r4)'
System::Free $1
IntOp $4 $4 - $9 ;reduce size of label
System::Call 'USER32::SetWindowPos(ir2,i,i,i,ir3,ir4,i6)'
System::Call 'USER32::CreateWindowEx(i0,t "Button",t "Some option",i ${__NSD_CheckBox_STYLE},ir6,ir7,ir8,ir9,ir0,i666,i0,i0)i.r2'
SendMessage $0 ${WM_GETFONT} 0 0 $0
SendMessage $2 ${WM_SETFONT} $0 1
${NSD_SetState} $2 1 ;check it
FunctionEnd
Function licleave
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 666
${NSD_GetState} $0 $1
MessageBox mb_ok "Checkbox=$1"
FunctionEnd