|
-
Apr 18th, 2002, 10:26 AM
#1
Thread Starter
Retired VBF Adm1nistrator
Reading information from another application's listbox
Just wondering if anyone has any code to hand to pull the data from another application's listbox or RTB ?
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Apr 18th, 2002, 12:56 PM
#2
Hyperactive Member
Im sure there is an API to do this.. you probably just need a handle to the other app.. check out the API board
-mcd
[vbcode]
'*****************************
MsgBox "MCD :: [email protected]", vbInformation + vbOKOnly, "User"
'*****************************
[/vbcode]
-
Apr 18th, 2002, 02:21 PM
#3
Frenzied Member
VB Code:
'\\ From the [b]ApiComboControl[/b] class:
Public Enum enComboBoxMessages
CB_ADDSTRING = &H143
CB_DELETESTRING = &H144
CB_DIR = &H145
CB_FINDSTRING = &H14C
CB_FINDSTRINGEXACT = &H158
CB_GETCOUNT = &H146
CB_GETCURSEL = &H147
CB_GETDROPPEDCONTROLRECT = &H152
CB_GETEDITSEL = &H140
CB_GETLBTEXT = &H148
CB_GETLBTEXTLEN = &H149
CB_INSERTSTRING = &H14A
CB_LIMITTEXT = &H141
CB_RESETCONTENT = &H14B
CB_SELECTSTRING = &H14D
CB_SETCURSEL = &H14E
CB_SETEDITSEL = &H142
CB_SHOWDROPDOWN = &H14F
CB_GETITEMDATA = &H150
CB_SETITEMDATA = &H151
CB_SETITEMHEIGHT = &H153
CB_GETITEMHEIGHT = &H154
CB_SETEXTENDEDUI = &H155
CB_GETEXTENDEDUI = &H156
CB_GETDROPPEDSTATE = &H157
CB_SETLOCALE = &H159
CB_GETLOCALE = &H15A
CB_GETTOPINDEX = &H15B
CB_SETTOPINDEX = &H15C
CB_GETHORIZONTALEXTENT = &H15D
CB_SETHORIZONTALEXTENT = &H15E
CB_GETDROPPEDWIDTH = &H15F
CB_SETDROPPEDWIDTH = &H160
CB_INITSTORAGE = &H161
CB_MULTIPLEADDSTRING = &H163
End Enum
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As enComboBoxMessages, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Property Get List(ByVal Index As Long) As String
If mHWND <> 0 Then
Dim lLen As String
Dim sList As String
lLen = SendMessageLong(mHWND, CB_GETLBTEXTLEN, Index, 0)
If lLen > 0 Then
sList = String$(lLen, 0)
Call SendMessageLong(mHWND, CB_GETLBTEXT, Index, StrPtr(sList))
If Err.LastDllError Then
ReportError Err.LastDllError, CLSNAME & ":List", GetLastSystemError
End If
End If
End If
End Property
-
Apr 18th, 2002, 03:17 PM
#4
Hyperactive Member
Speak of the devil.. there is its, you mention the acronym API and *poof* it appears!
-mcd
[vbcode]
'*****************************
MsgBox "MCD :: [email protected]", vbInformation + vbOKOnly, "User"
'*****************************
[/vbcode]
-
Jun 8th, 2005, 10:51 PM
#5
Hyperactive Member
Re: Reading information from another application's listbox
I tried that code and cant seem to get it to work, when I used it, sList comes back as "?????????"
any ideas?
-
Jun 8th, 2005, 11:28 PM
#6
Re: Reading information from another application's listbox
Thats because the example is for a Combo Box control and not a Listbox control. Just use the constants from the api guide that start with LB_.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 8th, 2005, 11:55 PM
#7
Hyperactive Member
Re: Reading information from another application's listbox
What LB things could I use?
for GETLBTEXTLEN I used LB_GETCOUNT
and for GETLBTEXT I used LB_GETTEXT
and it doesnt work, for slist I get 1 character reply now, and for ILen I get blank, before with GETLBTEXTLEN I would get an integer value.
any ideas?
-
Jun 8th, 2005, 11:59 PM
#8
Re: Reading information from another application's listbox
No, you cant just change the constant name. you need to also change the value.
VB Code:
Private Const LB_GETCOUNT As Long = &H18B
Private Const LB_GETCURSEL As Long = &H188
Private Const LB_GETTEXT As Long = &H189
Private Const LB_GETTEXTLEN As Long = &H18A
'Etc.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 9th, 2005, 12:08 AM
#9
Hyperactive Member
Re: Reading information from another application's listbox
Ihave those consts, I was asking if I was using the right ones. I already had all the values changed ,however it still isnt working.
-
Jun 9th, 2005, 12:16 AM
#10
Re: Reading information from another application's listbox
You need to make sure your using the correct window handle for the your listbox
VB Code:
lLen = SendMessageLong([color=red]mHWND[/color], LB_GETCOUNT, Index, 0)
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 9th, 2005, 12:20 AM
#11
Hyperactive Member
Re: Reading information from another application's listbox
I already said I switched those and it isnt working.
Why do you think I am suppost to use Listbox controls?
API spy says it is a combobox.
-
Jun 9th, 2005, 12:23 AM
#12
Hyperactive Member
Re: Reading information from another application's listbox
VB Code:
Public Const LB_GETCOUNT = &H18B
Public Const LB_GETTEXT = &H189
window = FindWindow("classname", vbNullString)
combobox = FindWindowEx(window, 0&, "ComboBox", vbNullString)
If combobox <> 0 Then
Dim lLen As String
Dim sList As String
Dim numItems As Long
lLen = SendMessageLong(combobox, LB_GETCOUNT, Index, 0)
If lLen > 0 Then
sList = String$(lLen, 0)
Call SendMessageLong(combobox, LB_GETTEXT, Index, StrPtr(sList))
End If
End If
This is my code , and lLen always comes up as 0, then sList is blank.
-
Jun 9th, 2005, 12:28 AM
#13
Hyperactive Member
Re: Reading information from another application's listbox
it is a combobox , so back to using the CB ones..
-
Jun 9th, 2005, 12:29 AM
#14
Hyperactive Member
Re: Reading information from another application's listbox
Whats index for in this code?
-
Jun 9th, 2005, 12:29 AM
#15
Re: Reading information from another application's listbox
Well seeing how this thread was on how to read a Listbox control in another program. You never said you were using a combo box.
You never posted any code until I PM'd you about it either.
I understand your frustration but I'm out of time tonight.
Sorry and thanks for the negative Rep point when I was just trying to help you. 
Robert
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 9th, 2005, 12:42 AM
#16
Hyperactive Member
Re: Reading information from another application's listbox
-
Jun 9th, 2005, 01:29 AM
#17
Hyperactive Member
Re: Reading information from another application's listbox
Sorry RedDog, I did eventually figure it out (well the jist of it), I was unclear and you misunderstood me, which in the end actually helped. I have a better understanding of it now.
Thanks
Last edited by manavo11; Jun 9th, 2005 at 04:03 PM.
Reason: Profanity
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|