试图将Web浏览器嵌入到c ++ Win32项目中。关于MyIOleInPlaceFrameTable的错误

时间:2011-10-21 00:03:06

标签: c++ visual-studio-2008 internet-explorer browser embed

有人能帮助我吗?我的目标是将一个子Web浏览器窗口放入我的C ++项目中。我从这里得到了一个示例代码:

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

然后尝试用VS 2008编译它。他们的示例项目编译并运行得很好。

然后使用相同的VS 2008,我开始将代码放入我的项目中,这也是用C ++编写的本机Win32 GUI应用程序。我将“Simple \ Simple.c”文件中的几乎所有代码一对一地添加到我的C ++项目中,但是当我尝试编译它时,我得到了一百万个错误消息,从这一个开始:

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

然后大约20个错误代码:

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

等等。

第一个错误将落在这一行:

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};

和第二行:

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

我还包括了原始项目中的所有内容:

#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()

就我而言,我无法弄清楚IOleInPlaceFrameVtbl和IOleClientSiteVtbl的定义位置。任何想法的人?

2 个答案:

答案 0 :(得分:2)

默认情况下,它将在C ++中定义C ++ OLE接口。要获得C样式接口,请在include之前添加

#define CINTERFACES

答案 1 :(得分:0)

检查文件扩展名是否为.cpp。更改为.c并重建。对我来说它工作得很好。