view是通过chtmlview类显示的网页,如何在其中加入广告位?

解决方案 »

  1.   


    IHTMLDocument2*   phtmldoc2   =   NULL;   
    IHTMLElement*   phtmlElement   =   NULL;   
    IDispatch*   pdisp   =   NULL;  
    IHTMLBodyElement* phtmlBodyElement = NULL;
    pdisp   =   this->GetHtmlDocument();   
    if(pdisp   !=   NULL)   
    {   
    pdisp->QueryInterface(IID_IHTMLDocument2,(void**)&phtmldoc2);   
    pdisp->Release();   
    }   

    if(phtmldoc2   !=   NULL)   
    {   
    phtmldoc2->get_body(&phtmlElement);
    phtmldoc2->Release();   
    }   
    if(phtmlElement   !=   NULL)   
    {   
    phtmlElement->insertAdjacentHTML("afterBegin","you ad code");//插入你的广告   
    }
    CHtmlView::OnDocumentComplete(lpszURL);
      

  2.   

    重载CHtmlView::OnDocumentComplete(LPCTSTR lpszURL)事件