我想用IHtmlDocument2将
CString aaa="#00ffff"的值作为背景。怎么实现???同样。我在向IHtmlDocument2中添加内容(比如图片时)。他会在前面加一个about:blank。用pDoc->put_url()也不行。怎么办让他添加图片时不显示about:blank?
CString aaa="#00ffff"的值作为背景。怎么实现???同样。我在向IHtmlDocument2中添加内容(比如图片时)。他会在前面加一个about:blank。用pDoc->put_url()也不行。怎么办让他添加图片时不显示about:blank?
如果需要设置背景,可以用IHtmlDocument2接口得到BODY元素接口之后调用它的方法。
FrontPage给网页添加图片的时候,是把文件复制到一个临时目录中,然后再插入文档。
{
HRESULT hr;
CString szTemp;
IHTMLDocument2* pDoc2 = (IHTMLDocument2* )m_htmlpage.GetHtmlDocument();
IHTMLSelectionObject* pSelection;
pDoc2->get_selection(&pSelection);
BSTR bstrValue;
IDispatch* pDisp;
hr = pSelection->createRange(&pDisp);
if(SUCCEEDED(hr) && pDisp!= NULL )
{
IHTMLTxtRange* pTextAreaElement;
hr = pDisp->QueryInterface(IID_IHTMLTxtRange,
(void**)&pTextAreaElement);
pTextAreaElement->get_text(&bstrValue);
szTemp = bstrValue;
szTemp = tagBegin + szTemp + tagEnd;
pTextAreaElement->pasteHTML( szTemp.AllocSysString());
pTextAreaElement->Release();
}else
{
AfxMessageBox("Error for create range");
}
::SysFreeString(bstrValue);
}
3ks
去看Implementing Edit Designers 2: The Annotator Sample