简体   繁体   English

NSIS运行时未创建按钮

[英]NSIS runtime not created buttons

I try to create Windows installer with radiobuttons page where the buttons are created runtime from found files path. 我尝试使用单选按钮页面创建Windows安装程序,其中从发现的文件路径在运行时创建按钮。 But only first file path is used for radiobutton creating only. 但是只有第一个文件路径仅用于单选按钮创建。 When I uncomment MessageBox line the all files path are shown. 当我取消注释MessageBox行时,将显示所有文件路径。 Could anybody help me please? 有人可以帮我吗?

Thanks 谢谢

Function getButtons
  nsDialogs::Create 1018
  Pop $dialog
  ${NSD_CreateGroupBox} 0 0 100% 100% "These DLLs were found installed"
  # get available plugins
  ${locate::Open} "$dllDir" `/F=1 /D=0 /M=*.dll /B=1` $0
  StrCmp $0 0 0 loop
  MessageBox MB_OK "Error! No DLL files found..., $dllDir" IDOK close

  loop:
  # counter for y value
  StrCpy $R1 10
  # find possible plugins for installation
  ${Do}
    ${locate::Find} $0 $1 $2 $3 $4 $5 $6
    ${If} $1 == ""
      ${ExitDo}
    ${EndIf}
    ;MessageBox MB_OK "Path=$1" IDOK
    # calculate radiobutton y value
    IntOp $R1 $R1 + 20
    ${NSD_CreateRadioButton} 20 $R1 100% 50% "$1"
    Pop $hwnd
    nsDialogs::SetUserData $hwnd "$1"
    ${NSD_OnClick} $hwnd RadioClick
  ${Loop}
  close:
  ${locate::Close} $0
  ${locate::Unload}
  nsDialogs::Show
FunctionEnd

The controls are all there, they are just not visible because you have set the height to 50% and the radio controls are not transparent. 控件都在那里,只是不可见,因为您已将高度设置为50%并且单选控件不是透明的。

You could make them transparent: 您可以使它们透明:

${NSD_CreateRadioButton} 20 $R1 100% 50% "$1"
Pop $hwnd
SetCtlColors $hwnd SYSCLR:8 Transparent ; NSIS 3.1+
${NSD_AddExStyle} $hwnd ${WS_EX_TRANSPARENT} ; https://blogs.msdn.microsoft.com/oldnewthing/20121217-00/?p=5823

but the NSIS documentation warns against this: 但是NSIS文档对此提出警告:

Warning: Setting the background color of check boxes to transparent may not function properly when using XPStyle on . 警告:在上使用XPStyle on时,将复选框的背景色设置为透明可能无法正常工作。 The background may be completely black instead of transparent when using certain Windows themes. 使用某些Windows主题时,背景可能是全黑而不是透明。

It is better to just size your controls correctly in the first place: 首先,最好正确调整控件的大小:

!include nsDialogs.nsh

Page Custom getButtons
Page InstFiles

var hwnd

Function getButtons
nsDialogs::Create 1018
Pop $0

${NSD_CreateGroupBox} 0 0 100% 100% "These DLLs were found installed"
Pop $0

StrCpy $R1 0 ; Measured in dialog units, not pixels
FindFirst $0 $1 "$sysdir\sh*.dll"
loop:
    StrCmp $1 "" end
    IntOp $R1 $R1 + 12
    ${NSD_CreateRadioButton} 5u $R1u -20 12u "$1"
    Pop $hwnd
    nsDialogs::SetUserData $hwnd "$1"
    ${NSD_OnClick} $hwnd RadioClick
    FindNext $0 $1
    Goto loop
end:
FindClose $0

nsDialogs::Show
FunctionEnd

If you don't know how many files there are then it is better to use a listbox so you don't run out of space in the dialog. 如果您不知道有多少文件,则最好使用列表框,以免对话框中空间不足。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM