PDA

Click to See Complete Forum and Search --> : Need to access combo box data


Steve Stunning
Dec 5th, 1999, 08:22 AM
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. :)

Serge
Dec 5th, 1999, 06:03 PM
Sure! This example will show you how to get all ComboBox items and put them in your Listbox:

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
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)

Steve Stunning
Dec 6th, 1999, 03:48 AM
Hey Serge,

I get a type mismatch error and it does not work. What am I doing wrong?

Serge
Dec 6th, 1999, 08:20 AM
Can you post the code snippet?

------------------

Serge

Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)

Steve Stunning
Dec 6th, 1999, 09:00 AM
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.