Can you help me?
But please do tell me I need to look to cefclient or to cefsimple project. I have been looking at it over and over again and I really can't see any solution there - I really need to create my own window and my own message loop, otherwise upgrade of the old project will be too complex.
Thanks.
- Code: Select all
#include <Windows.h>
#include <CommCtrl.h>
#include <tchar.h>
#include "MyCefClient.h"
#include "resource.h"
#include "include/cef_app.h"
#include "include/cef_browser.h"
INT_PTR CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDCANCEL:
SendMessage(hDlg, WM_CLOSE, 0, 0);
return TRUE;
}
break;
case WM_CLOSE:
if(MessageBox(hDlg, TEXT("Close the program?"), TEXT("Close"),
MB_ICONQUESTION | MB_YESNO) == IDYES)
{
DestroyWindow(hDlg);
}
return TRUE;
case WM_DESTROY:
CefQuitMessageLoop();
PostQuitMessage(0);
return TRUE;
}
return FALSE;
}
int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE h0, LPTSTR lpCmdLine, int nCmdShow)
{
HWND hDlg;
MSG msg;
BOOL ret;
InitCommonControls();
hDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DIALOG1), 0, DialogProc, 0);
ShowWindow(hDlg, nCmdShow);
HWND hGroupBox = GetDlgItem(hDlg, IDC_GROUPBOX1);
SetWindowText(hGroupBox, L"Chromium Embedded Output");
CefRefPtr<MyCefClient> cefHandler(new MyCefClient());
RECT rect;
GetClientRect(hGroupBox, &rect);
CefWindowInfo info;
info.SetAsChild(hGroupBox, rect);
CefBrowserSettings settings;
CefString path = "www.google.com";
CefBrowserHost::CreateBrowser(info, cefHandler.get(), path, settings);
while((ret = GetMessage(&msg, 0, 0, 0)) != 0)
{
if(ret == -1)
return -1;
if(!IsDialogMessage(hDlg, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 0;
}