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.I有Win32窗口(this-> m_hWnd),它假设是这个IWebBrowser2 com控件的父级。因为交叉线程问题,我将消息发布到线程创建IE控件并使用它。虽然调试它没有显示任何破损。但是,IE控件只显示空白,不显示任何页面。请帮助我解决问题。
答案 0 :(得分:0)
浏览器通过窗口消息异步操作。确保拥有浏览器窗口的线程的消息循环正在处理发往浏览器窗口的消息,例如在从线程的消息队列中检索它们之后将它们传递给TranslateMessage()
和DispatchMessage()
(如果它还没有这样做 - 很难说,因为你没有显示createUIThread()
之外ieThreadPorc()
所做的事情。)