ahmd0
ahmd0

Reputation: 17313

Trying to embed a web browser into a c++ Win32 project. Error about MyIOleInPlaceFrameTable

Can someone help me out. My goal is to put a child web browser window into my C++ project. I got a sample code from here:

http://www.codeproject.com/KB/COM/cwebpage.aspx

And then tried to compile it with VS 2008. Their sample project compiled and worked just fine.

Then using the same VS 2008 I started putting the code into my project, that is again, a native Win32 GUI application written in C++. I added almost all the code from "Simple\Simple.c" file one-to-one into my C++ project, but when I try to compile it I get a million error messages, starting with this one:

embed_htm_test.cpp(91) error C2146: syntax error : missing ';' before identifier 'MyIOleInPlaceFrameTable'
embed_htm_test.cpp(91) error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
embed_htm_test.cpp(91) error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

then about 20 error codes below:

embed_htm_test.cpp(158) : error C2146: syntax error : missing ';' before identifier 'MyIOleClientSiteTable'
embed_htm_test.cpp(158) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
embed_htm_test.cpp(158) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

and so on.

The first error would fall on this line:

IOleInPlaceFrameVtbl MyIOleInPlaceFrameTable = {Frame_QueryInterface,
Frame_AddRef,
Frame_Release,
Frame_GetWindow,
Frame_ContextSensitiveHelp,
Frame_GetBorder,
Frame_RequestBorderSpace,
Frame_SetBorderSpace,
Frame_SetActiveObject,
Frame_InsertMenus,
Frame_SetMenu,
Frame_RemoveMenus,
Frame_SetStatusText,
Frame_EnableModeless,
Frame_TranslateAccelerator};

and the second one on this line:

IOleClientSiteVtbl MyIOleClientSiteTable = {Site_QueryInterface,
Site_AddRef,
Site_Release,
Site_SaveObject,
Site_GetMoniker,
Site_GetContainer,
Site_ShowObject,
Site_OnShowWindow,
Site_RequestNewObjectLayout};

I also included all the includes from the original project:

#include <windows.h>
#include <exdisp.h>     // Defines of stuff like IWebBrowser2. This is an include file with Visual C 6 and above
#include <mshtml.h>     // Defines of stuff like IHTMLDocument2. This is an include file with Visual C 6 and above
#include <mshtmhst.h>   // Defines of stuff like IDocHostUIHandler. This is an include file with Visual C 6 and above
#include <crtdbg.h>     // for _ASSERT()

And for the best of me, I can't figure out where IOleInPlaceFrameVtbl and IOleClientSiteVtbl could be defined in. Any idea guys?

Upvotes: 0

Views: 1349

Answers (2)

darreng84
darreng84

Reputation: 9

Check if the file extension is .cpp. Change to .c and rebuild. For me it worked fine.

Upvotes: 0

edd
edd

Reputation: 21

By default in C++ it will define the C++ OLE interfaces. To get the C style interfaces, prior to the includes add

#define CINTERFACES

Upvotes: 2

Related Questions