Two checkboxes on a NSIS license page

有些话、适合烂在心里 提交于 2019-12-12 02:33:48

问题


I am trying to do pretty much what is being asked here but due to the complexity of the syntax and shortage of time, I need someone to help me out on this.

I have spent a couple of hours try to get TWO checkboxes shown instead of one but I keep failing. The NSIS syntax is killing me and I can't seem to get the params to the second USER32::CreateWindowEx right. I want to display the second checkbox below (or to the right) of the first one.

So far I have done the following modifications but this doesn't seem to create the second checkbox (please see the original post for the rest of the code).

; ---<snip>---
System::Call 'USER32::CreateWindowEx(i0,t "Button",t "Some option",i ${__NSD_CheckBox_STYLE},ir6,ir7,ir8,ir9,ir0,i666,i0,i0)i.r2'
System::Call 'USER32::CreateWindowEx(i0,t "Button",t "Second option",i ${__NSD_CheckBox_STYLE},ir6+100,ir7,ir8,ir9,ir0,i667,i0,i0)i.r3'
SendMessage $0 ${WM_GETFONT} 0 0 $0
SendMessage $2 ${WM_SETFONT} $0 1
SendMessage $3 ${WM_SETFONT} $0 1
${NSD_SetState} $2 1 ;check it
${NSD_SetState} $3 1 ;check it
FunctionEnd

Function licleave
FindWindow $5 "#32770" "" $HWNDPARENT
GetDlgItem $0 $5 666
GetDlgItem $1 $5 667
${NSD_GetState} $0 $0
${NSD_GetState} $1 $1
MessageBox mb_ok "Checkbox=$0 $1"
FunctionEnd

回答1:


You cannot do math like ir6+100 in a system::call (You can only OR simple numbers), try IntOp $6 $6 + 100 before you create the second checkbox.

Edit:

The code from the other answer also gave the checkbox the same width as the dialog so any other control added to the right of it will appear behind it.

You must adjust the size of the first checkbox as well:

...
IntOp $8 $8 / 2 ; Use half the width
System::Call 'USER32::CreateWindowEx(i0,t "Button",t "Some option",i ${__NSD_CheckBox_STYLE},ir6,ir7,ir8,ir9,ir0,i666,i0,i0)i.r2'
IntOp $6 $6 + $8 ; Offset 2nd checkbox by the width of the first
System::Call 'USER32::CreateWindowEx(i0,t "Button",t "Other option",i ${__NSD_CheckBox_STYLE},ir6,ir7,ir8,ir9,ir0,i667,i0,i0)i.r3'
...


来源:https://stackoverflow.com/questions/9670969/two-checkboxes-on-a-nsis-license-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!