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: