用IHtmlDocument2添加背景和页面地址

Gozhhu 2003-06-04 03:54:43
我想用IHtmlDocument2将
CString aaa="#00ffff"的值作为背景。怎么实现???

同样。我在向IHtmlDocument2中添加内容(比如图片时)。他会在前面加一个about:blank。用pDoc->put_url()也不行。怎么办让他添加图片时不显示about:blank?
...全文
79 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
蒋晟 2003-06-10
  • 打赏
  • 举报
回复
你怎么加入图片的?
蒋晟 2003-06-10
  • 打赏
  • 举报
回复
用IMarkService插入一个临时目录的文件吧
去看Implementing Edit Designers 2: The Annotator Sample
Gozhhu 2003-06-10
  • 打赏
  • 举报
回复
PastSelectionHTML("<IMG src=\"aaa.gif\">","</IMG>");

void CDlg::PasteSelectionHTML( CString tagBegin, CString tagEnd)
{
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
Gozhhu 2003-06-09
  • 打赏
  • 举报
回复
我是在一个页(c:\aaa.htm)用的IHtmlDocument2。但为什么还是about:blank?

谢谢。
蒋晟 2003-06-08
  • 打赏
  • 举报
回复
在访问DOM之前,浏览器需要一个基地址,所有的相对超级链接都基于这个地址。
如果需要设置背景,可以用IHtmlDocument2接口得到BODY元素接口之后调用它的方法。
FrontPage给网页添加图片的时候,是把文件复制到一个临时目录中,然后再插入文档。
曾经的猎狐 2003-06-07
  • 打赏
  • 举报
回复
up
Gozhhu 2003-06-05
  • 打赏
  • 举报
回复
即使我知道是put_bgColor我也不会。能否告知代码。谢谢

是添加一行<img src="相对位置"/>

它自动加的。
shuicai 2003-06-05
  • 打赏
  • 举报
回复
问题解决没有?学习。

你说的是添加一个没有源地址(文件)的图片控件吗?

描述清楚或许有建议
叶子哟 2003-06-04
  • 打赏
  • 举报
回复
put_bgColor

3,055

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC HTML/XML
社区管理员
  • HTML/XML社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧