Embedding Chromium in MFC application
Posted: Mon Oct 12, 2009 9:31 am
Hi,
I tried to embed Chromium using the Cef library into basic MFC SDI application. It doesn't work and I'm not sure what I'm doing wrong. I'm new to embedding chromium. What I have done until now:
1. I call CefInitialize(...) in Main Frame constructor:
2. I try to create a browser in overriden OnInitialUpdate method of my CView derived class:
3. In Main Frames destructor I call CefShutdown():
according to what the debugger says it should work, browser coordinates and dimensions are well set. Probably I'm missing something. Please let me know if you had any suggestions. I'm using winXP pro and building in Visual Studio 2008. I set all linker dependencies like cefclient example has, copied needed dlls into applications root directory and included cef.h. Thank you for your suggestions.
Best regards,
Martin
I tried to embed Chromium using the Cef library into basic MFC SDI application. It doesn't work and I'm not sure what I'm doing wrong. I'm new to embedding chromium. What I have done until now:
1. I call CefInitialize(...) in Main Frame constructor:
- Code: Select all
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
CefInitialize(false, std::wstring());
}
2. I try to create a browser in overriden OnInitialUpdate method of my CView derived class:
- Code: Select all
void Ccef_testView::OnInitialUpdate()
{
g_handler = new ClientHandler();//this is a global object declared like this: CefRefPtr<CefHandler> g_handler; ClientHandler is my implementation of CefHandler returning RV_CONTINUE in every method
CefWindowInfo info;
HWND hWnd = this->GetSafeHwnd();
RECT rect;
this->GetClientRect(&rect);
info.SetAsChild(hWnd, rect);
CefBrowser::CreateBrowser(info, false, static_cast<CefRefPtr<CefHandler>>(g_handler), _T("http://www.google.com"));//I assume now should I see the browser, but nothing happens
}
3. In Main Frames destructor I call CefShutdown():
- Code: Select all
CMainFrame::~CMainFrame()
{
CefShutdown();
}
according to what the debugger says it should work, browser coordinates and dimensions are well set. Probably I'm missing something. Please let me know if you had any suggestions. I'm using winXP pro and building in Visual Studio 2008. I set all linker dependencies like cefclient example has, copied needed dlls into applications root directory and included cef.h. Thank you for your suggestions.
Best regards,
Martin