Here is the code I use to start cef1:
- Code: Select all
// Create an instance of our CefClient implementation. Various methods in the
// MyClient instance will be called to notify about and customize browser
// behavior.
CefRefPtr<CefClient> Client(new rdk::cef_server::CCefRenderHandler());
// Information about the parent window, client rectangle, etc.
CefWindowInfo WindowInfo;
WindowInfo.SetAsOffScreen(hWndParent);
// Browser initialization settings.
CefBrowserSettings Settings;
memset(&Settings, 0, sizeof(Settings));
// Create the new browser window object asynchronously. This eventually results
// in a call to CefLifeSpanHandler::OnAfterCreated().
CefBrowser::CreateBrowser(WindowInfo, Client, L"http://www.google.com", Settings);
I zero out CefBrowserSettings because in the docs it says set to 0 or NULL for the default settings. The call to CefBrowser::CreateBrowser is what causes the crash.
Here is my CCefRenderHandler class definition:
- Code: Select all
class CCefRenderHandler : public CefClient, public CefRenderHandler
{
public:
CCefRenderHandler(void) :
m_iWidth(0),
m_iHeight(0)
{ }
~CCefRenderHandler(void) { }
void OnPaint(CefRefPtr<CefBrowser> Browser, PaintElementType Type,
const RectList& DirtyRects, const void* pBuffer) OVERRIDE;
private:
IMPLEMENT_REFCOUNTING(CCefClient);
int m_iWidth;
int m_iHeight;
}; // CCefRenderHandler
OnPaint is just an empty function for the time being.
The only message I get in the debugger is: cef_server_DEBUG.exe has triggered a breakpoint. When I click Break, it takes me to line 37 of browser_ctocpp.cc which contains this code:
- Code: Select all
// Execute
int _retval = cef_browser_create(
&windowInfo,
CefClientCppToC::Wrap(client),
url.GetStruct(),
&settings);
My code is based on the osrplugin example. Hopefully some of you can see what I am doing wrong. Thanks in advance.