Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Combobox: How to set the position to desired index

Posted on 2005-03-21
8
Medium Priority
?
287 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:sudhakar_koundinya
  • 5
  • 3
8 Comments
 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 13589613
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



0
 
LVL 5

Expert Comment

by:Rubyn
ID: 13590087
Tell me, to select an item in it, you have the position number or text.
0
 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 13590109
Text is preferred
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 5

Expert Comment

by:Rubyn
ID: 13590140
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 :)
0
 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 13590173
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
0
 
LVL 5

Accepted Solution

by:
Rubyn earned 1000 total points
ID: 13590209
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 Const CB_SETCURSEL = &H14E

Private Sub Command1_Click()
Dim hCombo As Long
    Let hCombo = Combo1.hwnd
    '-1 for null select, 0 for 1st item and so on
    If SendMessage(hCombo, CB_SETCURSEL, 1, 0) = 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
0
 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 13590236
Great Help. :-)
0
 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 13590259
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






0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question