In order to obtain the standard COM interface IDispach, type in CCntrItem add LPDISPATCH return data type for the GetIDispatch () function, which through the QueryInterface () method of the query interface IID_Idispatch be directed back to IDispach interface pointer:
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; |
In order to use the type library would require the use of type library to add the local "MSWord8.h" references (such as the use of Word 2000, will contain "MSWord9.h" reference). |