Emedded Word in vs 2003 not working in vs 2005

D

Daniel

I have embedded word into our application in vs 2003 and it works fine.

We have now moved up to vs 2005. It all compiles fine but when you run the
application and gets to the point where word is supposed to starts it crash.

It's not able to perform the call to Activate.

....
m_pEditView = (CView*)new CWnd();
m_pEditView->Attach(m_cntrl->hwnd());

TRY
{
m_pDoc = new COleDocument();
m_pItem = new COleDocObjectItem(m_pDoc);

CLSID clsid;
::CLSIDFromProgID(L"Word.Document",&clsid);

// Create the Word embedded item.
m_pItem->CreateNewItem(clsid);

m_pItem->Activate(OLEIVERB_SHOW, m_pEditView);


}
CATCH(CException, e)
....

If I debug, I'll se that the call:
SCODE sc = m_lpObject->DoVerb(nVerb, lpMsg, lpClientSite, -1,
hWnd, lpPosRect);
in:
void COleClientItem::Activate(LONG nVerb, CView* pView, LPMSG lpMsg)
in the file olecli3.cpp fails with a returncode.
I tried to google the return and didn't a single hit.

I have tried to search for information about this and what have changed
between vs 2003 and vs 2005 with no luck.

Anyone got any ideas what the problem might be and what to do about it?
 
D

Daniel

Some more information regarding the problem:

I've converted the return code to hex and it's an access violation code.
That doesn't help me much.

I've debugged in vs 2003 and vs 2005 and the difference seems to be the
lpClientSite parameter.

In vs 2003 it looks like this:

- lpClientSite 0x02de5a8c IOleClientSite *
- [COleClientItem::XOleClientSite] {...} COleClientItem::XOleClientSite
- IOleClientSite {...} IOleClientSite
- IUnknown {...} IUnknown
- __vfptr 0x7c158c90 const COleClientItem::XOleClientSite::`vftable' *
[0] 0x7c2b9420 COleClientItem::XOleClientSite::QueryInterface(const _GUID
&, void * *) *
[1] 0x7c2b93e0 COleClientItem::XOleClientSite::AddRef(void) *
[2] 0x7c2b9400 COleClientItem::XOleClientSite::Release(void) *
- IUnknown {...} IUnknown
- __vfptr 0x7c158c90 const COleClientItem::XOleClientSite::`vftable' *
[0] 0x7c2b9420 COleClientItem::XOleClientSite::QueryInterface(const _GUID
&, void * *) *
[1] 0x7c2b93e0 COleClientItem::XOleClientSite::AddRef(void) *
[2] 0x7c2b9400 COleClientItem::XOleClientSite::Release(void) *

And in vs 2005 it looks like this:

- lpClientSite 0x026e75f0 {lpVtbl=0x785fc6b8 } IOleClientSite *
- lpVtbl 0x785fc6b8 const COleClientItem::XOleClientSite::`vftable'
{QueryInterface=0x787118e0 AddRef=0x78711880 Release=0x787118b0
....} IOleClientSiteVtbl *
QueryInterface 0x787118e0
COleClientItem::XOleClientSite::QueryInterface(const _GUID &, void *
*) HRESULT (IOleClientSite *, const _GUID *, void * *)*
AddRef 0x78711880 COleClientItem::XOleClientSite::AddRef(void) unsigned
long (IOleClientSite *)*
Release 0x787118b0 COleClientItem::XOleClientSite::Release(void) unsigned
long (IOleClientSite *)*
SaveObject 0x78711910
COleClientItem::XOleClientSite::SaveObject(void) HRESULT (IOleClientSite *)*
GetMoniker 0x78711a00 COleClientItem::XOleClientSite::GetMoniker(unsigned
long, unsigned long, IMoniker * *) HRESULT (IOleClientSite *, unsigned long,
unsigned long, IMoniker * *)*
GetContainer 0x78711ce0
COleClientItem::XOleClientSite::GetContainer(IOleContainer * *) HRESULT
(IOleClientSite *, IOleContainer * *)*
ShowObject 0x78711d70
COleClientItem::XOleClientSite::ShowObject(void) HRESULT (IOleClientSite *)*
OnShowWindow 0x78711e60
COleClientItem::XOleClientSite::OnShowWindow(int) HRESULT (IOleClientSite *,
int)*
RequestNewObjectLayout 0x78765200
COleControlSite::XOleControlSite::ShowPropertyFrame(void) HRESULT
(IOleClientSite *)*


The code looks like this:
....
// prepare DoVerb parameters and call into the server
LPOLECLIENTSITE lpClientSite = GetClientSite();
HWND hWnd = pView->GetSafeHwnd();
SCODE sc = m_lpObject->DoVerb(nVerb, lpMsg, lpClientSite, -1,
hWnd, lpPosRect);
....

LPOLECLIENTSITE COleClientItem::GetClientSite()
{
ASSERT_VALID(this);

LPOLECLIENTSITE lpClientSite =
(LPOLECLIENTSITE)GetInterface(&IID_IOleClientSite);
ASSERT(lpClientSite != NULL);
return lpClientSite;
}
 
Top