int CIMChat::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1; CCreateContext pContext;
CWnd* pFrameWnd =this;
pContext.m_pCurrentDoc = new CMyDocument;
pContext.m_pNewViewClass = RUNTIME_CLASS(CHtmlView);//CHTMLEdView
m_WebViewRecv =(CHtmlView*)((CFrameWnd*)pFrameWnd)->CreateView(&pContext);//CHTMLEdView
ASSERT(m_WebViewRecv);
m_WebViewRecv->ShowWindow(SW_NORMAL);
CRect rectWindow;
rectWindow.left=10;
rectWindow.bottom=50;
rectWindow.right =50;
rectWindow.top =1;
m_WebViewRecv->MoveWindow(rectWindow);//10,140,840,620
m_WebViewRecv->Navigate( L"about:blank" ,NULL,NULL,NULL,NULL) ; pContext.m_pCurrentDoc = new CMyDocument;
pContext.m_pNewViewClass = RUNTIME_CLASS(IHtmlEditView);//CHTMLEdView
m_WebViewSend =(IHtmlEditView*)((CFrameWnd*)pFrameWnd)->CreateView(&pContext);//CHTMLEdView
ASSERT(m_WebViewSend);
m_WebViewSend->ShowWindow(SW_NORMAL);
rectWindow.left=10;
rectWindow.bottom=50;
rectWindow.right =50;
rectWindow.top =1;
m_WebViewSend->MoveWindow(rectWindow);  //10,140,840,620//
m_WebViewSend->Navigate( L"about:blank" ,NULL,NULL,NULL,NULL) ;
HRESULT hr;
LPDISPATCH pDisp; pDisp = m_WebViewRecv->GetHtmlDocument();
hr = pDisp->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&spDocRecv);
ASSERT(spDocRecv);
pDisp->Release(); m_WebViewSend->GetDHtmlDocument(&spDocSend);
ASSERT(spDocSend); return 0;
}
代码如上,在一个dialog里面!创建之后spDocRecv,spDocSend得不到指针在window2000下,而且会弹出一个对话框显示下在创建错误日志,在xp下有时也会得不到!请问一下是为什么?

解决方案 »

  1.   

    CHtmlView                            *m_WebViewRecv;//
    IHtmlEditView                        *m_WebViewSend;// CFont                                 m_FontStyle; IHTMLDocument2                        *spDocRecv;
    IHTMLDocument2                        *spDocSend;             上面的变量如下 !!