|
-
Dec 5th, 1999, 09:22 AM
#1
Thread Starter
Hyperactive Member
I would like to learn how to extract data from a combo box in another program. I can identify the hwnd but do not know how to get the information.
Please help.
-
Dec 5th, 1999, 07:03 PM
#2
Sure! This example will show you how to get all ComboBox items and put them in your Listbox:
Code:
Private Declare Function SendMessageString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) 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 CB_GETCOUNT = &H146
Private Const CB_GETLBTEXT = &H148
Private Const CB_GETLBTEXTLEN = &H149
Public Sub FromComboToList(pComboHwnd As ComboBox, pList As ListBox)
Dim lCount As Long
Dim lLen As Long
Dim strBuffer As String
Dim i As Integer
lCount = SendMessage(pComboHwnd, CB_GETCOUNT, 0, 0)
For i = 0 To lCount - 1
lLen = SendMessage(pComboHwnd, CB_GETLBTEXTLEN, i, 0)
strBuffer = Space(lLen)
Call SendMessageString(pComboHwnd, CB_GETLBTEXT, i, strBuffer)
pList.AddItem strBuffer
Next
End Sub
Usage: FromComboToList ComboboxHandle, DestinationListBox
Example: FromComboToList ComboHwnd, List1
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
-
Dec 6th, 1999, 04:48 AM
#3
Thread Starter
Hyperactive Member
Hey Serge,
I get a type mismatch error and it does not work. What am I doing wrong?
-
Dec 6th, 1999, 09:20 AM
#4
Can you post the code snippet?
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
-
Dec 6th, 1999, 10:00 AM
#5
Thread Starter
Hyperactive Member
Serge,
That is ok... I have found an excellent working example tonight. I am learning how to do it from there.
Thank you for your assistance.
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
|