Re: get text from listbox



Yes, still the same garbled output.
Tried your code, but it gives me the same.
Had a go with AccessibleObjectFromPoint and that is an
interesting API, but gave me question marks as output.
So no progress yet.
I suppose it just isn't a standard Windows listbox.

RBS


"Karl E. Peterson" <karl@xxxxxxxx> wrote in message news:%23aPTJGq9FHA.2120@xxxxxxxxxxxxxxxxxxxxxxx
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/



.



Relevant Pages

  • Re: Reading an listbox
    ... Dim nCount As Long, i As Long ... Dim Buffer() As Byte ... ' Check if we have a Unicode window? ...
    (microsoft.public.vb.general.discussion)
  • Re: struct & array user define type
    ... to get the individual file content from a Filecontents buffer? ... How to assign binary memory data to the previous define struct and get ... > Private Type SizeAPI ... > Dim StructLen As Long ...
    (microsoft.public.vb.winapi)
  • Pingen
    ... End Enum ... ' Buffer ICMP Type Feld ... Private Const bufferHeaderSize As Integer = 8 ... Dim RemoteHost As IPEndPoint ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • Re: Get current logged-in user
    ... Dim bytesReturned As UInt32 ... WTSInfoClass.WTSUserName, buffer, bytesReturned) ... WTSClientBuildNumber ... Public Shared Function WTSQuerySessionInformation(ByVal hServer As ...
    (microsoft.public.dotnet.general)
  • =?iso-8859-1?Q?Bild_=FCber_TCP-Verbindung_=FCbertragen?=
    ... Private Sub SendData(ByVal data As String) ... Dim writer As New IO.StreamWriter ... Static Buffer As String ...
    (microsoft.public.de.german.entwickler.dotnet.vb)

Loading