尝试将网络浏览器嵌入到 c++ Win32 项目。关于 MyIOleInPlaceFrameTable 的错误

发布于 2024-12-11 00:41:45 字数 2377 浏览 0 评论 0原文

有人可以帮我吗。我的目标是将一个子 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 可以在哪里定义。大家有什么想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心欲静而疯不止 2024-12-18 00:41:45

默认情况下,在 C++ 中它将定义 C++ OLE 接口。要获得 C 风格的接口,请在包含之前添加

#define CINTERFACES

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

#define CINTERFACES
山有枢 2024-12-18 00:41:45

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文