PDA

Click to See Complete Forum and Search --> : Listbox API


HeLta_SkeLta
Dec 29th, 1999, 09:59 AM
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.

Aaron Young
Dec 30th, 1999, 11:53 AM
You need the SendMessage API with the LB_GETTEXT API Constant, ie.

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
aarony@redwingsoftware.com
ajyoung@pressenter.com