Results 1 to 5 of 5

Thread: Need to access combo box data

  1. #1

    Thread Starter
    Hyperactive Member Steve Stunning's Avatar
    Join Date
    Jul 1999
    Location
    Fairfax, Virginia
    Posts
    314

    Post


    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.

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    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


  3. #3

    Thread Starter
    Hyperactive Member Steve Stunning's Avatar
    Join Date
    Jul 1999
    Location
    Fairfax, Virginia
    Posts
    314

    Post

    Hey Serge,

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

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Can you post the code snippet?

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

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


  5. #5

    Thread Starter
    Hyperactive Member Steve Stunning's Avatar
    Join Date
    Jul 1999
    Location
    Fairfax, Virginia
    Posts
    314

    Post

    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
  •  



Click Here to Expand Forum to Full Width