Re: get text from listbox
- From: "Karl E. Peterson" <karl@xxxxxxxx>
- Date: Thu, 1 Dec 2005 10:03:27 -0800
RB Smissaert wrote:
> Trying to get the text of items in a listbox of an external
> application.
Hard to tell from the thread if you're still having issues with this. But I
wrote this long ago, and it works great for standard listboxes:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
Any) As Long
Private Const LB_GETTEXT = &H189
Private Const LB_GETTEXTLEN = &H18A
Private Const LB_GETCOUNT = &H18B
Private Const LB_ERR = (-1)
' Within some routine, assuming you have a valid hWnd...
Dim nCount As Long, i As Long
Dim TxtLen As Long
Dim Buffer As String
nCount = SendMessage(hWnd, LB_GETCOUNT, 0&, ByVal 0&)
If nCount <> LB_ERR Then
For i = 0 To nCount - 1
TxtLen = SendMessage(hWnd, LB_GETTEXTLEN, i, ByVal 0&)
If Len(Buffer) < (TxtLen + 1) Then
Buffer = Space$(TxtLen + 1)
End If
If SendMessage(hWnd, LB_GETTEXT, i, ByVal Buffer) <> LB_ERR Then
Debug.Print Left$(Buffer, TxtLen)
End If
Next i
End If
Later... Karl
--
Working without a .NET?
http://classicvb.org/
.
- Follow-Ups:
- Re: get text from listbox
- From: RB Smissaert
- Re: get text from listbox
- References:
- get text from listbox
- From: RB Smissaert
- get text from listbox
- Prev by Date: Re: 10-band equalizer
- Next by Date: Re: get text from listbox
- Previous by thread: Re: get text from listbox
- Next by thread: Re: get text from listbox
- Index(es):
Relevant Pages
|
Loading