Link to home
Start Free TrialLog in
Avatar of sudhakar_koundinya
sudhakar_koundinya

asked on

Combobox: How to set the position to desired index

Hi all,

I have a handle to combox box(this is from external application- App A).

Now I want to set the value to desired position using my application(App - B)

How can I do this??

Thanks
Sudhakar
Avatar of sudhakar_koundinya
sudhakar_koundinya

ASKER

I have found this method

Private  Declare Function DlgDirSelectComboBoxEx Lib "user32" Alias "DlgDirSelectComboBoxExA" (ByVal hWndDlg As Long, ByVal lpszPath As String, ByVal cbPath As Long, ByVal idComboBox As Long) As Long
But facing problem

Could you please help me??

Thanks
sudhakar



Tell me, to select an item in it, you have the position number or text.
Text is preferred
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_SELECTSTRING = &H14D

Private Sub Command1_Click()
Dim hCombo As Long
    Let hCombo = Combo1.hwnd
    If SendMessage(hCombo, CB_SELECTSTRING, -1, ByVal "World") = 0 Then
        MsgBox "Not Found"
    End If
End Sub

Private Sub Form_Load()
    Call Combo1.AddItem("Hello")
    Call Combo1.AddItem("World")
    Call Combo1.AddItem("Rubyn")
End Sub

Put one Combo and Command on a form and paste the code
Want any help inform me :)
Ok thanks,
 It seems I am facing some problem with text selection. May I have an exampple based on index??

If that works, I will change my logic accoringly

Thanks
Sudhakar
ASKER CERTIFIED SOLUTION
Avatar of Rubyn
Rubyn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great Help. :-)
Actually I am working with Office Outlook 2003  project. And I am facing some problems

So, in order to resolve these problems, I need to use Win API's Message Sending procedures.
As of now I have tested this with MFC- VB Communication.

When I am at work place,  will test the same with 2003. If I get any problems, I will post new queries here. And I hope you will be there to help me.

Thanks Again


Regards
Sudhakar