Hi DirectuX,
it is solution mostly by Win32API, but seems to work:
function GetSelectedListboxItems(hDlg as dword, hCtl as long, byref out_result() as string) as long
long selectionCount
long hList
control handle hDlg, hCtl to hList
selectionCount = SendMessage(hList, %LB_GETSELCOUNT, 0, 0)
if selectionCount > 0 then
long itemIndexes(selectionCount)
SendMessage(hList, %LB_GETSELITEMS, selectionCount, varptr(itemIndexes(1)))
' Fit the output array to selection count
redim out_result(selectionCount)
' Limited to 512 characters, feel free to adjust
dim singleTextItem as asciiz * 512
' Extract all items from ListBox
for i as long = 1 to selectionCount
SendMessage(hList, %LB_GETTEXT, itemIndexes(i), varptr(singleTextItem))
out_result(i) = singleTextItem
next
return selectionCount
end if
end function
You can use it like:
string items()
long selectedCount = GetSelectedListboxItems(hDlg, %myListBox, items)
if selectedCount then msgbox hDlg, join$(items, ",")
Petr
Bookmarks