During the process of "sign in" to login.live or via msdn.com page the DHTML generated form appears to be misbehaving such that having found the first IHTMLElement
element with tagName "input" and converting that to a IHTMLInputElement
field can see it has the type="text", however it fails to provide the IHTMLInputTextElement
interface when queried. Neither are any of the other input fields providing interfaces for their specific types.
In comparison the same process works just fine when hitting http://gmail.com.
I'm at a loss as to the source of this error, DHTML, login.live, the moon in the wrong phase? Get the same issue on IE7 and IE8 so doesn't appear to be version specific. Get the same issue regardless of IE compatibility mode.
Here is a quick example
TSharedField Factory( CComPtr<IHTMLElement>& _Element )
{
CComQIPtr<IHTMLTextAreaElement> TextAreaField = _Element;
if (TextAreaField)
return TSharedField(new Text(TextAreaField));
CComQIPtr<IHTMLInputTextElement> TextField = _Element;
if (TextField)
return TSharedField(new Text(TextField));
CComQIPtr<IHTMLInputButtonElement> ButtonField = _Element;
if (ButtonField)
return TSharedField(new Button(ButtonField));
CComQIPtr<IHTMLInputFileElement> FileField = _Element;
if (FileField)
return TSharedField(new CWebField_File(FileField));
CComQIPtr<IHTMLInputHiddenElement> HiddenField = _Element;
if (HiddenField)
return TSharedField(new Hidden(HiddenField));
CComQIPtr<IHTMLOptionButtonElement> BooleanField = _Element;
if (BooleanField)
return TSharedField(new Boolean(BooleanField));
CComQIPtr<IHTMLSelectElement> SelectionField = _Element;
if (SelectionField)
return TSharedField(new Select(SelectionField));
CComQIPtr<IHTMLInputImage> ImageField = _Element;
if (ImageField)
return TSharedField(new Image(ImageField));
// Added for debug, only gets hit on login.live
std::wstring type;
HRESULT hr;
DOM_SIMPLE_GET_STRING( type, _Element, get_tagName, hr);
::OutputDebugString( type.c_str() );
if( type == L"INPUT" ){
CComQIPtr<IHTMLInputElement> Input = _Element;
if( Input){
DOM_SIMPLE_GET_STRING( type, Input, get_type, hr);
::OutputDebugString( (type+L"\n").c_str() );
}
}
return TSharedField();
}
Hey Greg, I work on a BHO that uses Input elements so your issue intrigued me. After some extensive testing I hit the same wall as you. After the DocumentComplete event fires and you try to QI either the name and password elements for their IHTMLInputTextElement interface it fails. However, I've found you can successfully sink them with the HTMLInputTextElementEvents interface, which leads me to conclude that the cause of this issue is a result of a bug in MSHTML. Rest assured the moon's phase is A-OK. Now, what are the chances of getting the IE team to look in to this ?