- Code: Select all
#include "include/cef_browser.h"
#include "include/cef_client.h"
#include "include/cef_command_line.h"
#include "include/cef_frame.h"
#include "include/cef_runnable.h"
#include "include/cef_web_plugin.h"
#include "clienthandler.h"
#include "cefapplicationhandler.h"
// Global variables
// The main window class name.
CefRefPtr<clienthandler> g_handler(new clienthandler);
CefRefPtr<CefBrowser> browser;
// Forward declarations of functions included in this code module:
//
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
{
CefQuitMessageLoop();
PostQuitMessage(0);
return 0;
}
break;
case WM_CREATE:
{
RECT rect;
GetClientRect(hWnd, &rect);
CefWindowInfo info;
info.SetAsChild(hWnd, rect);
CefBrowserSettings settings;
std::string path = "file:///C:/Users/GBM/Documents/Visual%20Studio%202010/Projects/cefapplication1/cefapplication1/index.html";
CefBrowserHost::CreateBrowserSync(info, g_handler.get(),path, settings);
}
break;
case WM_COMMAND:
{
}
break;
}
return DefWindowProc(hWnd,msg,wParam,lParam);
}
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
{
// Register the window class.
const wchar_t CLASS_NAME[] = L"Sample Window Class";
WNDCLASS wc = { };
wc.lpfnWndProc = WndProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;
RegisterClass(&wc);
CefRefPtr<cefapplicationhandler> cefApplication(new cefapplicationhandler);
CefMainArgs main_args(hInstance);
CefSettings appSettings;
appSettings.multi_threaded_message_loop = true ;
CefString(&appSettings.browser_subprocess_path).FromASCII("C:\Users\GBM\Documents\Visual Studio 2010\Projects\cefapplication1\Release");
// Create the window.
CefInitialize(main_args,appSettings, cefApplication.get());
HWND hwnd = CreateWindowEx(
0, // Optional window styles.
CLASS_NAME, // Window class
L"Learn to Program Windows", // Window text
WS_OVERLAPPEDWINDOW, // Window style
// Size and position
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional application data
);
if (hwnd == NULL)
{
return 0;
}
ShowWindow(hwnd, nCmdShow);
MSG msg;
BOOL bRet;
while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
CefShutdown();
return 0;
hi all in the above code i have set CefSettings.multi_threaded_message_loop = true and dont call the cefrunmessageloop(). The window tries to come up and hungs up without creating the entire window. How to solve this issue????