Announcement

Collapse
No announcement yet.

sendmessage and combobox's

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Borje Hagsten
    replied
    Not sure I understand. You want to send messages from a DLL written in
    PB to a program written in VB? Pass the hWnd property from VB to the
    DLL and then use standard API in DLL, like:
    Code:
    '--------------------------------------------------------------
    ' PB CODE - simple DLL
    ' (save as My.bas and compile to DLL in same folder as VB prog)
    '--------------------------------------------------------------
    #COMPILE DLL "MY.DLL"
    #INCLUDE "WIN32API.INC"
    SUB SetVBCBSel(BYVAL hWnd AS LONG, BYVAL item AS LONG) EXPORT
      IF hWnd THEN
         SendMessage hWnd, %CB_SETCURSEL, item, 0
         'SendMessage GetParent(hWnd), %WM_COMMAND, MAKLNG(GetDlgCtrlID(hWnd), %CBN_DBLCLK), hWnd     'for Combo1_DblClick event
         SendMessage GetParent(hWnd), %WM_COMMAND, MAKLNG(GetDlgCtrlID(hWnd), %CBN_SELCHANGE), hWnd  'for Combo1_Click() event
         'Note - notifications goes to parent (form), then VB passes on to internal event handler.
      END IF
    END SUB
     
    '--------------------------------------------------------------
    ' VB CODE - One form, one ComboBox with style 2 (dropdown list)
    ' and one button. Compile and then run EXE to test.
    '--------------------------------------------------------------
    Private Declare Sub SetVBCBSel Lib "My.Dll" Alias "SETVBCBSEL" (ByVal hWnd As Long, ByVal item As Long)
     
    Private Sub Combo1_DblClick()
      MsgBox "This is VB talking - Combo1_DblClick was triggered from DLL!!"
    End Sub
    
    Private Sub Combo1_Click()
      MsgBox "This is VB talking - Combo1_Click was triggered from DLL!!"
    End Sub
     
    Private Sub Command1_Click()
      SetVBCBSel Combo1.hWnd, 2 'select third item via DLL..
    End Sub
     
    Private Sub Form_Load()
        Dim I As Long
        For I = 1 To 10
            Combo1.AddItem "Item number " + CStr(I)
        Next I
    End Sub

    ------------------
    Okay, first only did DblClick, then saw you wanted Click event, so
    added way to trigger that one too..



    [This message has been edited by Borje Hagsten (edited September 26, 2001).]

    Leave a comment:


  • Thomas Tierney
    started a topic sendmessage and combobox's

    sendmessage and combobox's

    Hi all,
    I am currently finishing up a QA defect tracking system and automated
    test manager for the company I currently work for..
    since this will automate setup up of the software and GUI Testing
    I have a need to make various inputs via sendmessage..
    I have most of the requirements finished with the exception of
    combobox selections.. these are the dropdown listbox's provided
    by Visual Basic(ComboBox control set to dropdown listbox)...
    I have tried several methods to generate a click event to the combo
    box control and nothing seems to work, any IDEA?


    thanks


    ------------------
Working...
X