NSIS:获取选定列表框项的索引

NSIS: Getting the index of a selected ListBox Item

我正在动态填充使用 ${NSD_CreateListBox} 创建的列表框。在一个函数中,我能够获取所选文本,但是否有可能获取所选项目的索引?

${NSD_LB_GetSelection} $hCtl_parallelInstall_Installed [=11=]是什么returns全文而已?

非常感谢

nsDialogs 在 Windows UI 控件库中没有针对每条消息的宏,因此有时您必须直接从 MSDN 获取信息,但在这种情况下,该宏存在于最近NSIS 的版本,但尚未记录。如果您使用的是旧版本,您可以自己添加宏:

!include nsDialogs.nsh
!ifndef NSD_LB_GetSelectionIndex
!define NSD_LB_GetSelectionIndex `!insertmacro __NSD_LB_GetSelectionIndex `
!macro __NSD_LB_GetSelectionIndex CONTROL VAR
    SendMessage ${CONTROL} ${LB_GETCURSEL} 0 0 ${VAR}
!macroend
!endif

...

${NSD_LB_GetSelectionIndex} $hCtl_parallelInstall_Installed [=10=]