扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
LPDISPATCH GetIDispatch(); 其函数实现如下: LPDISPATCH CEmbed_WordCntrItem::GetIDispatch() { ASSERT_VALID(this); ASSERT(m_lpObject != NULL); LPUNKNOWN lpUnk = m_lpObject; Run(); LPOLELINK lpOleLink = NULL; if(m_lpObject->QueryInterface(IID_IOleLink,(LPVOID FAR*)&lpOleLink)== NOERROR) { ASSERT(lpOleLink != NULL); lpUnk = NULL; if(lpOleLink->GetBoundSource(&lpUnk) != NOERROR) { TRACE0("Warning: Link is not connected!\n"); lpOleLink->Release(); } ASSERT(lpUnk != NULL); } LPDISPATCH lpDispatch = NULL; if(lpUnk->QueryInterface(IID_IDispatch,(LPVOID FAR*)&lpDispatch) != NOERROR) { TRACE0("Waring: does not support IDispatch!\n"); return NULL; } ASSERT(lpDispatch != NULL); return lpDispatch; } |
void CEmbed_WordView::EmbedAutomateWord() { BeginWaitCursor(); CEmbed_WordCntrItem* pItem = NULL; TRY { CEmbed_WordDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); pItem = new CEmbed_WordCntrItem(pDoc); ASSERT_VALID(pItem); GetClientRect(&pItem->rect); CLSID clsid; if(FAILED(::CLSIDFromProgID(L"Word.document",&clsid))) AfxThrowMemoryException(); if(!pItem->CreateNewItem(clsid)) AfxThrowMemoryException(); ASSERT_VALID(pItem); pItem->DoVerb(OLEIVERB_SHOW, this); m_pSelection = pItem; pDoc->UpdateAllViews(NULL); LPDISPATCH lpDisp; lpDisp = pItem->GetIDispatch(); } CATCH(CException, e) { if (pItem != NULL) { ASSERT_VALID(pItem); pItem->Delete(); } AfxMessageBox(IDP_FAILED_TO_CREATE); } END_CATCH EndWaitCursor(); } |
void CEmbed_WordView::OnInitialUpdate() { CView::OnInitialUpdate(); EmbedAutomateWord(); //将Word嵌入 m_pSelection = NULL; } |
void CEmbed_WordView::OnDraw(CDC* pDC) { CEmbed_WordDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (m_pSelection == NULL) { POSITION pos = pDoc->GetStartPosition(); m_pSelection = (CEmbed_WordCntrItem*)pDoc->GetNextClientItem(pos); } if (m_pSelection != NULL) { CRect rect; GetClientRect(&m_pSelection->rect); m_pSelection->OnGetItemPosition(rect); m_pSelection->Draw(pDC,rect); } } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者