在的"sign in" to login.live或via msdn.com page的DHTML生成形式的過程似乎是錯誤操作,使得在找到一個第一IHTMLElement
元件用的tagName「輸入」和轉換,要一個IHTMLInputElement
字段可以看到它具有類型=「文本」,然而,它在查詢時未能提供IHTMLInputTextElement
界面。其他任何輸入字段都不爲其特定類型提供接口。InternetExplorer在BHO中輸入標籤類型文本不轉換爲IHTMLInputTextElement?
相比之下,當擊中時,同樣的過程也很好。
我對這個錯誤的來源感到茫然,DHTML,login.live,月亮在錯誤的階段? 在IE7和IE8上獲取相同的問題,因此似乎不是特定於版本的。 無論IE兼容模式如何,都會遇到同樣的問題。
下面是一個簡單的例子
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();
}
看起來更專業的接口只是沒有創建,所以我已經使用IHTMLInputElement和檢查get_type值。因爲我需要支持IE6-IE9,我猜這是最好的解決辦法,直到它被修復。 – 2011-03-19 02:13:48