QueryInterfac需要一个LPVOID*参数,不能直接用IHTMLxxx*的。
可以定义一个LPVOID传进去,然后再转换。

解决方案 »

  1.   

    pFrame->QueryInterface(IID_IHTMLWindow2, (void **)&pWindow)
    item的第二个参数是VARIANT *
      

  2.   

    我的函数是这么写的:void CTalkView::OnDownloadCompleteExplorer1() 
    {


        IHTMLElementCollection *objAllElement=NULL;
        IHTMLDocument2 *objDocument=NULL;
        CComPtr<IDispatch>pDisp;
        IHTMLAnchorElement *objAnchor=NULL;    CString strUrl;
        strUrl=m_web.GetLocationURL();
        if(strUrl.IsEmpty())
            return;
        objDocument=(IHTMLDocument2 *)m_web.GetDocument();//得到主document IHTMLFramesCollection2 * pFrameCol;
    objDocument->get_frames(&pFrameCol);//得到frame
    ASSERT(pFrameCol);
      
    IHTMLFrameBase * pFrame;
    pFrameCol->item((VARIANT *)2, (VARIANT *)&pFrame);  // 得到第二个frame
    ASSERT(pFrame); IHTMLWindow2* pWindow;
    pFrame->QueryInterface(IID_IHTMLWindow2, (void**)&pWindow);
    ASSERT(pWindow); IHTMLDocument2 * psubDoc;
    pWindow->get_document(&psubDoc);//得到第二个框架的document指针
    ASSERT(psubDoc);    
    psubDoc->get_all(&objAllElement);
             objAllElement->item(COleVariant("phone"),COleVariant((long)0),&pDisp);
             //得到id为“phone”的网页控件的指针
             CComQIPtr<IHTMLElement, &IID_IHTMLElement>pElement;
             pElement=pDisp;
             pElement->click();

    }程序运行老是死掉,不知道我什么地方对
      

  3.   

    IHTMLFrameBase2::contentWindow Property--------------------------------------------------------------------------------Retrieves the IHTMLWindow2 object of the specified IHTMLFrameElement or IHTMLIFrameElement.