Board index » cppbuilder » Combobox and Dropdown Box Interfaces?

Combobox and Dropdown Box Interfaces?


2005-08-04 03:13:49 AM
cppbuilder4
Can anyone tell me the correct mshtml interface so that I can read/set the
values and names of comboboxes and drop down lists displayed in a browser.
I've tried Gambit's...
TComInterface<IHTMLDocument2>Doc;
ActiveBrowser->Document->QueryInterface(IID_IHTMLDocument2,
(LPVOID*)&Doc);
if( Doc )
{
TComInterface<IHTMLElementCollection>All;
Doc->get_all(&All);
if( All )
{
long count = 0;
All->get_length(&count);
for(long idx = 0; idx < count; ++idx)
{
TVariant item = idx;
TVariant index = 0;
TComInterface<IDispatch>Disp;
All->item(item, index, &Disp);
if( Disp )
{ TComInterface<IHTMLInputElement>Input;
Disp->QueryInterface(IID_IHTMLInputElement,(LPVOID*)
&Input);
// AND Also tried
//TComInterface<IHTMLInputTextElement>Input;
//Disp->QueryInterface(IID_IHTMLInputTextElement,(LPVOID*)
&Input);
if( Input )
{ ...
... but it just skips over my combo boxes displayed in the browser. I need
to be able to see the combo box's name and set/read the selected value of
the box.
Thanks for looking.
Mitch
 
 

Re:Combobox and Dropdown Box Interfaces?

"Mitch McInelly" < XXXX@XXXXX.COM >wrote in message
Quote
it just skips over my combo boxes displayed in the browser.
Of course it does, because you did not code in the ComboBox interfaces. You
did not read the MSHTML interface documentation, did you?
msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/interface.asp
ComboBoxes are not handled by the <input>HTML tag to begin with, so
IHTMLInputElement is the wrong interface to use. ComboBoxes are handled by
the <select>HTML tag instead, and thus you should be using the
IHTMLSelectElement interface instead. The individual items of the list are
contained in <option>tags inside the <select>so you can use the
IHTMLSelectElement's item() method to retreive the IHTMLOptionElement
interface for each item in the list.
Gambit
 

Re:Combobox and Dropdown Box Interfaces?

Of course...
I did read the documentation but got stuck thinking the edit component of
the combobox would be inherited from InputElement rather than SelectElement.
Thanks for the help - once again.
Mitch
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Mitch McInelly" < XXXX@XXXXX.COM >wrote in message
news:42f1176b$ XXXX@XXXXX.COM ...

>it just skips over my combo boxes displayed in the browser.

Of course it does, because you did not code in the ComboBox interfaces.
You
did not read the MSHTML interface documentation, did you?


msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/interface.asp

ComboBoxes are not handled by the <input>HTML tag to begin with, so
IHTMLInputElement is the wrong interface to use. ComboBoxes are handled
by
the <select>HTML tag instead, and thus you should be using the
IHTMLSelectElement interface instead. The individual items of the list
are
contained in <option>tags inside the <select>so you can use the
IHTMLSelectElement's item() method to retreive the IHTMLOptionElement
interface for each item in the list.


Gambit


 

{smallsort}