Попытка встраивания веб-браузера в проект c Win32. Ошибка в MyIOleInPlaceFrameTable

#c #visual-studio-2008 #internet-explorer #browser #embed

#c #visual-studio-2008 #internet-explorer #браузер #Внедрить

Вопрос:

Может кто-нибудь мне помочь. Моя цель — поместить дочернее окно веб-браузера в мой проект C . Я получил пример кода отсюда:

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

А затем попытался скомпилировать его с помощью VS 2008. Их примерный проект скомпилирован и работал просто отлично.

Затем, используя тот же VS 2008, я начал вставлять код в свой проект, то есть, опять же, собственное приложение Win32 GUI, написанное на C . Я добавил почти весь код из файла «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. Есть идеи, ребята?

Ответ №1:

По умолчанию в C он определяет OLE-интерфейсы C . Чтобы получить интерфейсы в стиле C, перед включением добавьте

 #define CINTERFACES
  

Ответ №2:

Проверьте, является ли расширение файла .cpp. Измените на .c и перестройте. Для меня это сработало нормально.