Google Answers Logo
View Question
 
Q: VB - How to you change a combobox value of another application using an API ( No Answer,   0 Comments )
Question  
Subject: VB - How to you change a combobox value of another application using an API
Category: Computers > Programming
Asked by: rcearley-ga
List Price: $10.00
Posted: 29 Sep 2002 19:32 PDT
Expires: 01 Oct 2002 09:36 PDT
Question ID: 70635
Hello,

I am writing an application in visual basic that automates another
application through the use of system message APIs.

Here's what it does.  It first finds a dialog box with the "Export
Data" title in it.  It then finds the first combo box in it and then
changes the value in it.  This codes changes the value in the combobox
without any problems.

The problem I'm having is that the dialog box doesn't seem to know
that the combobox has changed.  If I change the value of the combobox
with my mouse, then the form reloads the other listboxes with
different values based off of the value that is in the combobox.  If I
use SETSURSEL  then the combobox gets the new value, but the listboxes
doesn't reload.  I need the listboxes to reload as if I selected a new
combobox item with my mouse.

Can anyone give me a working example of how to do this in visual basic
6?

Thanks,
Rob

Const CB_SETCURSEL = &H14E
Const CBN_SELCHANGE = 1
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const CBN_CLOSEUP = 8

'Get the handle for the export data dialog box - this works 
Do While exporthwnd = 0
    exporthwnd = FindWindow(vbNullString, "Export Data")
    DoEvents
Loop

'Get the handle of the combobox dropdown, which is in the export data
dialog box - this works
cbohndle = FindWindowEx(exporthwnd, &H0&, "ComboBox", vbNullString)

'Select an item - this works
SendMessage(cbohndle, CB_SETCURSEL, 2, 0)

'Select the item -- notify the parent that there's been a change
'this doesn't work
PostMessage exporthwnd, WM_COMMAND, CBN_SELCHANGE, cbohndle
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy