Hello,
I am trying to get the string from a ListBox but am unable to do so.
I use LB_GETTEXT with the following syntax in eVB:
Dim hConnWin As Long
Dim count As Long ' number of items in the list box
Dim curIndx As Long ' index of the currently selected item
Dim itemtext As String ' text of that item
Dim textlen As Long ' length of the item text
hConnWin = FindWindow("listbox", "")
If hConnWin <> 0 Then
'Now I have the list-box
count = SendMessage(hConnWin, LB_GETCOUNT, CLng(0), CLng(0))
[I get a correct count]
curIndx = SendMessage(hConnWin, LB_GETCURSEL, 0, 0)
[I get the correct index]
textlen = SendMessage(hConnWin, LB_GETTEXTLEN, curIndx, CLng(0))
[I get the correct textlength]
itemtext = Space(textlen) & vbNullChar
textlen = SendMessage(hConnWin, LB_GETTEXT, curIndx, itemtext)
[ I don't get anything in itemtext!!]
itemtext = Mid(itemtext, 1, textlen)
End If
My SendMessage Declare function:
Public Declare Function SendMessage Lib "Coredll" Alias "SendMessageW" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Variant _
) As Long
What am I doing wrong? Is it wrong to use textlen to allocate space for the
itemtext String? Are there any UNICODE issues here?
NOTE: As you may have noticed this code is in a different process from the
one where the listbox is.
Is there any sort of an issue with LB_GETTEXT across processes?
Please help!
--
Regards,
Sami