CComQIPtr<IHTMLElement> spEleColl;
spHTMLDoc3->get_documentElement(&spEleColl); //得到文档的根节点
CComPtr<IHTMLElementCollection> spEleCollAll;
HRESULT hr = spEleColl->get_all(&spEleCollAll); //获取当前元素下的所有元素的 HtmlElementCollection是不是属性或是接口弄错了..spEleCollAll的值一直为空?
spHTMLDoc3->get_documentElement(&spEleColl); //得到文档的根节点
CComPtr<IHTMLElementCollection> spEleCollAll;
HRESULT hr = spEleColl->get_all(&spEleCollAll); //获取当前元素下的所有元素的 HtmlElementCollection是不是属性或是接口弄错了..spEleCollAll的值一直为空?
CComPtr<IDispatch> spDisp;
spEleColl->get_all(&spDisp);
CComQIPtr<IHTMLElementCollection> spEleCollAll = spDisp;
hr = spHTMLDoc2->createElement(_T("style"), (IHTMLElement**)&spStyleEle); //创建元素style
if (FAILED (hr) || !spStyleEle)
{
return;
}
//IHTMLElement::get_Style之后用IHTMLStyleElement的方法设置风格
CComBSTR bstroldtype, bstrnewtype; /*spStyleEle ->get_type (&bstroldtype);
bstrnewtype = _T("text/css");
hr = spStyleEle ->put_type (bstrnewtype);
if (FAILED (hr))
{
return;
}*/
CComPtr<IHTMLStyleSheet> spStyleSheet;
hr = spStyleEle->get_styleSheet(&spStyleSheet);
if (FAILED (hr) || !spStyleSheet)
{
return;
} //TODO:字符串拼接
STYLE_xarios_main.Append (STYLE_xarios_main_left);
STYLE_xarios_main.Append (STYLE_xarios_main_right);
STYLE_xarios_main.Append (STYLE_xarios_main_text);
STYLE_xarios_main.Append (STYLE_xarios_main_blank);
STYLE_xarios_main.Append (STYLE_contextmenu);
STYLE_xarios_main.Append (STYLE_contextmenuitem);
STYLE_xarios_main.Append (STYLE_contextmenuitem_hover); spStyleSheet->put_cssText(STYLE_xarios_main); CComPtr<IHTMLDOMNode> spNewNode2, spNewNodeBack2;
spNewNode2 = spStyleEle;
hr = spNode->appendChild(spNewNode2, &spNewNodeBack2);
if (FAILED (hr) || !spNewNodeBack2)
{
return;
}
CComPtr<IHTMLElement> spEleColl;
hr = spHTMLDoc3->get_documentElement(&spEleColl); //得到文档的根节点
if (FAILED (hr) || !spEleColl)
{
return;
} CComPtr <IDispatch> spDisp;
hr = spEleColl->get_all(&spDisp);
CComQIPtr <IHTMLElementCollection> spEleCollAll = spDisp;就是我把那个get_type 和PUT_TYPE注释了后又编译过去了...怎么回事呢