0
    void CUIPopupWnd::ieThreadProc(MSG* msg, LPVOID lpParameter){

    CUIPopupWnd *ptrPopUpWndCtrl = (CUIPopupWnd*)GetWindowLongPtr((HWND)msg->wParam , GWLP_USERDATA);
    switch(msg->message)
    {
    case WM_IECREATE:
        {
            REPORT_INTERNAL_SW_ERROR_EXT(L"HTML frame is going to be created.");        
            ptrPopUpWndCtrl->m_htmlAttributes.pBrowser = new (nothrow)CUIHTMLFrameWnd((HWND)msg->wParam,ptrPopUpWndCtrl->m_ulPresentWidth,ptrPopUpWndCtrl->m_ulPresentHeight);              

            if( NULL == ptrPopUpWndCtrl->m_htmlAttributes.pBrowser )
            {
                REPORT_INTERNAL_SW_ERROR_EXT(L"EmbeddedBrowser failed");
            }
            else
            {
                //m_htmlAttributes.pBrowser->createControl(this->m_hWnd,this->m_ulPresentWidth,this->m_ulPresentHeight);
                ptrPopUpWndCtrl->m_htmlAttributes.pBrowser->m_currentURL = ptrPopUpWndCtrl->m_htmlAttributes.m_szHTMLPath;
                ptrPopUpWndCtrl->m_htmlAttributes.pBrowser->RepaintBrowser();
                ptrPopUpWndCtrl->m_htmlWindowsList.push_front(ptrPopUpWndCtrl);
                ptrPopUpWndCtrl->m_htmlAttributes.pBrowser->Navigate(ptrPopUpWndCtrl->m_htmlAttributes.pBrowser->m_currentURL);
            }           
        }
        break;
    case WM_IEREFRESH:
        {           
            ptrPopUpWndCtrl->m_htmlAttributes.pBrowser->Navigate(ptrPopUpWndCtrl->m_htmlAttributes.pBrowser->m_currentURL);
            ptrPopUpWndCtrl->m_htmlAttributes.m_fReloadRequired = false;

        }
        break;  
    default:
        return;
    }

    CThreadController::getThreadController().createUIThread( ieThreadProc, IEThread,NULL );
            CThreadController::getThreadController().postThreadMessage(IEThread,WM_IECREATE,(_wparam)this->m_hWnd,0);

CThreadController::getThreadController().postThreadMessage(IEThread,WM_IEREFRESH,(_wparam)this->m_hWnd,0);

在这里,ieThreadProc 是一个静态线程 proc。我有 Win32 窗口(this->m_hWnd),它应该是这个 IWebBrowser2 com 控件的父级。由于跨线程问题,我将消息发布到 IE 控件所在的线程创建并使用它。在调试时它没有显示任何破损。但是,IE 控件只是显示空白,没有显示页面。请帮助我解决问题。

4

1 回答 1

0

The browser operates asynchronously via window messages. Make sure that the message loop of the thread that owns the browser window is processing messages that are destined for the browser's window, such as by passing them to TranslateMessage() and DispatchMessage() after retreiving them from the thread's message queue (if it is not already doing so - it is hard to say since you do not show what createUIThread() does outside of ieThreadPorc()).

于 2012-07-20T20:32:22.450 回答