谁能帮帮我。我的目标是将一个子 Web 浏览器窗口放入我的 C++ 项目中。我从这里得到了示例代码:
http://www.codeproject.com/KB/COM/cwebpage.aspx
然后尝试使用 VS 2008 对其进行编译。他们的示例项目已编译并运行良好。
然后使用相同的 VS 2008,我开始将代码放入我的项目中,这又是一个用 C++ 编写的 native 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 可以在哪里定义。有想法吗?
最佳答案
默认情况下,在 C++ 中,它将定义 C++ OLE 接口(interface)。要获得 C 风格的接口(interface),在包含之前添加
#define CINTERFACES
关于c++ - 尝试将 Web 浏览器嵌入到 C++ Win32 项目中。关于 MyIOleInPlaceFrameTable 的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7843670/