Results 1 to 2 of 2

Thread: Listbox API

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 1999
    Posts
    23

    Post

    I know there is an API call that will retrieve the contents of a list box from another program. But, I don't know which one. If anyone knows what API to use and how to use it please tell me. Thank you.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    You need the SendMessage API with the LB_GETTEXT API Constant, ie.
    Code:
    Private Type POINTAPI
            x As Long
            y As Long
    End Type
    
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    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_GETCOUNT = &H18B
    Private Const LB_GETTEXT = &H189
    Private Const LB_GETTEXTLEN = &H18A
    
    Private Sub Command1_Click()
        Dim tPOS As POINTAPI
        Dim lHwnd As Long
        Dim lCount As Long
        Dim lIndex As Long
        Dim lLen As Long
        Dim sItem As String
        
        Call GetCursorPos(tPOS)
        lHwnd = WindowFromPoint(tPOS.x, tPOS.y)
        lCount = SendMessage(lHwnd, LB_GETCOUNT, 0&, ByVal 0&)
        List1.Clear
        While lIndex < lCount
            lLen = SendMessage(lHwnd, LB_GETTEXTLEN, lIndex, ByVal 0&)
            sItem = Space(lLen)
            Call SendMessage(lHwnd, LB_GETTEXT, lIndex, ByVal sItem)
            List1.AddItem sItem
            lIndex = lIndex + 1
        Wend
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width