我想用IHtmlDocument2将
CString aaa="#00ffff"的值作为背景。怎么实现???同样。我在向IHtmlDocument2中添加内容(比如图片时)。他会在前面加一个about:blank。用pDoc->put_url()也不行。怎么办让他添加图片时不显示about:blank?

解决方案 »

  1.   

    即使我知道是put_bgColor我也不会。能否告知代码。谢谢是添加一行<img src="相对位置"/>它自动加的。
      

  2.   

    在访问DOM之前,浏览器需要一个基地址,所有的相对超级链接都基于这个地址。
    如果需要设置背景,可以用IHtmlDocument2接口得到BODY元素接口之后调用它的方法。
    FrontPage给网页添加图片的时候,是把文件复制到一个临时目录中,然后再插入文档。
      

  3.   

    我是在一个页(c:\aaa.htm)用的IHtmlDocument2。但为什么还是about:blank?谢谢。
      

  4.   

    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
      

  5.   

    用IMarkService插入一个临时目录的文件吧
    去看Implementing Edit Designers 2: The Annotator Sample