2009-07-24 21:11:01 +02:00
|
|
|
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2008-12-02 16:48:14 +01:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "cef.h"
|
2009-08-21 19:41:09 +02:00
|
|
|
#include "cefclient.h"
|
|
|
|
#include "binding_test.h"
|
|
|
|
#include "extension_test.h"
|
|
|
|
#include "plugin_test.h"
|
|
|
|
#include "resource_util.h"
|
|
|
|
#include "scheme_test.h"
|
|
|
|
#include "string_util.h"
|
2009-08-21 21:43:37 +02:00
|
|
|
#include "uiplugin_test.h"
|
2008-12-02 16:48:14 +01:00
|
|
|
#include <sstream>
|
|
|
|
|
2009-05-28 02:31:21 +02:00
|
|
|
|
2008-12-02 16:48:14 +01:00
|
|
|
#define MAX_LOADSTRING 100
|
|
|
|
#define MAX_URL_LENGTH 255
|
2009-07-24 21:11:01 +02:00
|
|
|
#define BUTTON_WIDTH 72
|
2008-12-02 16:48:14 +01:00
|
|
|
#define URLBAR_HEIGHT 24
|
|
|
|
|
2009-01-29 19:53:17 +01:00
|
|
|
// Define this value to run CEF with messages processed using the current
|
|
|
|
// application's message loop.
|
2009-03-06 20:20:44 +01:00
|
|
|
#define TEST_SINGLE_THREADED_MESSAGE_LOOP
|
2009-01-29 19:53:17 +01:00
|
|
|
|
2008-12-02 16:48:14 +01:00
|
|
|
// Global Variables:
|
|
|
|
HINSTANCE hInst; // current instance
|
|
|
|
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
|
|
|
|
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
|
|
|
|
|
|
|
|
// Forward declarations of functions included in this code module:
|
|
|
|
ATOM MyRegisterClass(HINSTANCE hInstance);
|
|
|
|
BOOL InitInstance(HINSTANCE, int);
|
|
|
|
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
|
|
|
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
|
|
|
|
2009-08-21 04:14:47 +02:00
|
|
|
|
|
|
|
// Program entry point function.
|
2008-12-02 16:48:14 +01:00
|
|
|
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
|
|
|
HINSTANCE hPrevInstance,
|
|
|
|
LPTSTR lpCmdLine,
|
|
|
|
int nCmdShow)
|
|
|
|
{
|
2009-01-29 19:53:17 +01:00
|
|
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
|
|
|
UNREFERENCED_PARAMETER(lpCmdLine);
|
|
|
|
|
|
|
|
#ifdef TEST_SINGLE_THREADED_MESSAGE_LOOP
|
|
|
|
// Initialize the CEF with messages processed using the current application's
|
|
|
|
// message loop.
|
2009-03-06 20:20:44 +01:00
|
|
|
CefInitialize(false, std::wstring());
|
2009-01-29 19:53:17 +01:00
|
|
|
#else
|
|
|
|
// Initialize the CEF with messages processed using a separate UI thread.
|
2009-03-06 20:20:44 +01:00
|
|
|
CefInitialize(true, std::wstring());
|
2009-01-29 19:53:17 +01:00
|
|
|
#endif
|
2008-12-02 16:48:14 +01:00
|
|
|
|
2009-08-21 19:41:09 +02:00
|
|
|
// Register the internal client plugin.
|
|
|
|
InitPluginTest();
|
|
|
|
|
2009-08-21 21:43:37 +02:00
|
|
|
// Register the internal UI client plugin.
|
|
|
|
InitUIPluginTest();
|
|
|
|
|
2009-08-21 19:41:09 +02:00
|
|
|
// Register the V8 extension handler.
|
|
|
|
InitExtensionTest();
|
2009-08-21 04:14:47 +02:00
|
|
|
|
2009-08-21 19:41:09 +02:00
|
|
|
// Register the scheme handler.
|
|
|
|
InitSchemeTest();
|
|
|
|
|
2009-01-29 19:53:17 +01:00
|
|
|
MSG msg;
|
|
|
|
HACCEL hAccelTable;
|
|
|
|
|
|
|
|
// Initialize global strings
|
|
|
|
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
|
|
|
LoadString(hInstance, IDC_CEFCLIENT, szWindowClass, MAX_LOADSTRING);
|
|
|
|
MyRegisterClass(hInstance);
|
|
|
|
|
|
|
|
// Perform application initialization
|
|
|
|
if (!InitInstance (hInstance, nCmdShow))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_CEFCLIENT));
|
|
|
|
|
|
|
|
// Main message loop
|
|
|
|
while (GetMessage(&msg, NULL, 0, 0))
|
|
|
|
{
|
|
|
|
#ifdef TEST_SINGLE_THREADED_MESSAGE_LOOP
|
|
|
|
// Allow the CEF to do its message loop processing.
|
|
|
|
CefDoMessageLoopWork();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
|
|
|
|
{
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
|
|
|
}
|
2008-12-02 16:48:14 +01:00
|
|
|
|
|
|
|
// Shut down the CEF
|
|
|
|
CefShutdown();
|
|
|
|
|
|
|
|
return (int) msg.wParam;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// FUNCTION: MyRegisterClass()
|
|
|
|
//
|
|
|
|
// PURPOSE: Registers the window class.
|
|
|
|
//
|
|
|
|
// COMMENTS:
|
|
|
|
//
|
|
|
|
// This function and its usage are only necessary if you want this code
|
|
|
|
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
|
|
|
|
// function that was added to Windows 95. It is important to call this
|
|
|
|
// function so that the application will get 'well formed' small icons
|
|
|
|
// associated with it.
|
|
|
|
//
|
|
|
|
ATOM MyRegisterClass(HINSTANCE hInstance)
|
|
|
|
{
|
|
|
|
WNDCLASSEX wcex;
|
|
|
|
|
|
|
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
|
|
|
|
|
|
|
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
|
|
|
wcex.lpfnWndProc = WndProc;
|
|
|
|
wcex.cbClsExtra = 0;
|
|
|
|
wcex.cbWndExtra = 0;
|
|
|
|
wcex.hInstance = hInstance;
|
|
|
|
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_CEFCLIENT));
|
|
|
|
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
|
|
|
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
|
|
|
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_CEFCLIENT);
|
|
|
|
wcex.lpszClassName = szWindowClass;
|
|
|
|
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
|
|
|
|
|
|
|
|
return RegisterClassEx(&wcex);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// FUNCTION: InitInstance(HINSTANCE, int)
|
|
|
|
//
|
|
|
|
// PURPOSE: Saves instance handle and creates main window
|
|
|
|
//
|
|
|
|
// COMMENTS:
|
|
|
|
//
|
|
|
|
// In this function, we save the instance handle in a global variable and
|
|
|
|
// create and display the main program window.
|
|
|
|
//
|
|
|
|
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|
|
|
{
|
|
|
|
HWND hWnd;
|
|
|
|
|
|
|
|
hInst = hInstance; // Store instance handle in our global variable
|
|
|
|
|
|
|
|
hWnd = CreateWindow(szWindowClass, szTitle,
|
|
|
|
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT, 0, CW_USEDEFAULT,
|
|
|
|
0, NULL, NULL, hInstance, NULL);
|
|
|
|
|
|
|
|
if (!hWnd)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ShowWindow(hWnd, nCmdShow);
|
|
|
|
UpdateWindow(hWnd);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-05-28 02:31:21 +02:00
|
|
|
|
2008-12-02 16:48:14 +01:00
|
|
|
// Client implementation of the browser handler class
|
|
|
|
class ClientHandler : public CefThreadSafeBase<CefHandler>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ClientHandler()
|
|
|
|
{
|
|
|
|
m_MainHwnd = NULL;
|
|
|
|
m_BrowserHwnd = NULL;
|
|
|
|
m_EditHwnd = NULL;
|
|
|
|
m_bLoading = false;
|
|
|
|
m_bCanGoBack = false;
|
|
|
|
m_bCanGoForward = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
~ClientHandler()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Event called before a new window is created. The |parentBrowser| parameter
|
|
|
|
// will point to the parent browser window, if any. The |popup| parameter
|
|
|
|
// will be true if the new window is a popup window. If you create the window
|
|
|
|
// yourself you should populate the window handle member of |createInfo| and
|
|
|
|
// return RV_HANDLED. Otherwise, return RV_CONTINUE and the framework will
|
|
|
|
// create the window. By default, a newly created window will recieve the
|
|
|
|
// same handler as the parent window. To change the handler for the new
|
|
|
|
// window modify the object that |handler| points to.
|
|
|
|
virtual RetVal HandleBeforeCreated(CefRefPtr<CefBrowser> parentBrowser,
|
|
|
|
CefWindowInfo& createInfo, bool popup,
|
|
|
|
CefRefPtr<CefHandler>& handler,
|
|
|
|
std::wstring& url)
|
|
|
|
{
|
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Event called after a new window is created. The return value is currently
|
|
|
|
// ignored.
|
|
|
|
virtual RetVal HandleAfterCreated(CefRefPtr<CefBrowser> browser)
|
|
|
|
{
|
|
|
|
Lock();
|
|
|
|
if(!browser->IsPopup())
|
|
|
|
{
|
|
|
|
// We need to keep the main child window, but not popup windows
|
|
|
|
m_Browser = browser;
|
|
|
|
m_BrowserHwnd = browser->GetWindowHandle();
|
|
|
|
}
|
|
|
|
Unlock();
|
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Event called when the address bar changes. The return value is currently
|
|
|
|
// ignored.
|
|
|
|
virtual RetVal HandleAddressChange(CefRefPtr<CefBrowser> browser,
|
2009-05-28 02:31:21 +02:00
|
|
|
CefRefPtr<CefFrame> frame,
|
2008-12-02 16:48:14 +01:00
|
|
|
const std::wstring& url)
|
|
|
|
{
|
2009-05-28 02:31:21 +02:00
|
|
|
if(m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain())
|
2009-03-06 20:20:44 +01:00
|
|
|
{
|
|
|
|
// Set the edit window text
|
|
|
|
SetWindowText(m_EditHwnd, url.c_str());
|
|
|
|
}
|
2008-12-02 16:48:14 +01:00
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Event called when the page title changes. The return value is currently
|
|
|
|
// ignored.
|
|
|
|
virtual RetVal HandleTitleChange(CefRefPtr<CefBrowser> browser,
|
|
|
|
const std::wstring& title)
|
|
|
|
{
|
|
|
|
// Set the frame window title bar
|
2009-03-06 20:20:44 +01:00
|
|
|
HWND hwnd = browser->GetWindowHandle();
|
|
|
|
if(!browser->IsPopup())
|
|
|
|
{
|
|
|
|
// The frame window will be the parent of the browser window
|
|
|
|
hwnd = GetParent(hwnd);
|
|
|
|
}
|
|
|
|
SetWindowText(hwnd, title.c_str());
|
2008-12-02 16:48:14 +01:00
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Event called before browser navigation. The client has an opportunity to
|
|
|
|
// modify the |request| object if desired. Return RV_HANDLED to cancel
|
|
|
|
// navigation.
|
|
|
|
virtual RetVal HandleBeforeBrowse(CefRefPtr<CefBrowser> browser,
|
2009-05-28 02:31:21 +02:00
|
|
|
CefRefPtr<CefFrame> frame,
|
2008-12-02 16:48:14 +01:00
|
|
|
CefRefPtr<CefRequest> request,
|
|
|
|
NavType navType, bool isRedirect)
|
|
|
|
{
|
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2009-05-28 02:31:21 +02:00
|
|
|
// Event called when the browser begins loading a page. The |frame| pointer
|
|
|
|
// will be empty if the event represents the overall load status and not the
|
|
|
|
// load status for a particular frame. The return value is currently ignored.
|
|
|
|
virtual RetVal HandleLoadStart(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame)
|
2008-12-02 16:48:14 +01:00
|
|
|
{
|
2009-07-24 20:37:00 +02:00
|
|
|
if(!browser->IsPopup() && !frame.get())
|
2009-05-28 02:31:21 +02:00
|
|
|
{
|
|
|
|
Lock();
|
|
|
|
// We've just started loading a page
|
|
|
|
m_bLoading = true;
|
|
|
|
m_bCanGoBack = false;
|
|
|
|
m_bCanGoForward = false;
|
|
|
|
Unlock();
|
|
|
|
}
|
2008-12-02 16:48:14 +01:00
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2009-05-28 02:31:21 +02:00
|
|
|
// Event called when the browser is done loading a page. The |frame| pointer
|
|
|
|
// will be empty if the event represents the overall load status and not the
|
|
|
|
// load status for a particular frame. This event will be generated
|
|
|
|
// irrespective of whether the request completes successfully. The return
|
|
|
|
// value is currently ignored.
|
|
|
|
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame)
|
2008-12-02 16:48:14 +01:00
|
|
|
{
|
2009-07-24 20:37:00 +02:00
|
|
|
if(!browser->IsPopup() && !frame.get())
|
2009-05-28 02:31:21 +02:00
|
|
|
{
|
|
|
|
Lock();
|
|
|
|
// We've just finished loading a page
|
|
|
|
m_bLoading = false;
|
|
|
|
m_bCanGoBack = browser->CanGoBack();
|
|
|
|
m_bCanGoForward = browser->CanGoForward();
|
|
|
|
Unlock();
|
|
|
|
}
|
2008-12-02 16:48:14 +01:00
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2009-05-28 02:31:21 +02:00
|
|
|
// Called when the browser fails to load a resource. |errorCode| is the
|
2008-12-02 16:48:14 +01:00
|
|
|
// error code number and |failedUrl| is the URL that failed to load. To
|
|
|
|
// provide custom error text assign the text to |errorText| and return
|
|
|
|
// RV_HANDLED. Otherwise, return RV_CONTINUE for the default error text.
|
|
|
|
virtual RetVal HandleLoadError(CefRefPtr<CefBrowser> browser,
|
2009-05-28 02:31:21 +02:00
|
|
|
CefRefPtr<CefFrame> frame,
|
2008-12-02 16:48:14 +01:00
|
|
|
ErrorCode errorCode,
|
|
|
|
const std::wstring& failedUrl,
|
|
|
|
std::wstring& errorText)
|
|
|
|
{
|
|
|
|
if(errorCode == ERR_CACHE_MISS)
|
|
|
|
{
|
|
|
|
// Usually caused by navigating to a page with POST data via back or
|
|
|
|
// forward buttons.
|
|
|
|
errorText = L"<html><head><title>Expired Form Data</title></head>"
|
|
|
|
L"<body><h1>Expired Form Data</h1>"
|
|
|
|
L"<h2>Your form request has expired. "
|
|
|
|
L"Click reload to re-submit the form data.</h2></body>"
|
|
|
|
L"</html>";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// All other messages.
|
|
|
|
std::wstringstream ss;
|
|
|
|
ss << L"<html><head><title>Load Failed</title></head>"
|
|
|
|
L"<body><h1>Load Failed</h1>"
|
|
|
|
L"<h2>Load of URL " << failedUrl <<
|
|
|
|
L"failed with error code " << static_cast<int>(errorCode) <<
|
|
|
|
L".</h2></body>"
|
|
|
|
L"</html>";
|
|
|
|
errorText = ss.str();
|
|
|
|
}
|
|
|
|
return RV_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Event called before a resource is loaded. To allow the resource to load
|
|
|
|
// normally return RV_CONTINUE. To redirect the resource to a new url
|
|
|
|
// populate the |redirectUrl| value and return RV_CONTINUE. To specify
|
|
|
|
// data for the resource return a CefStream object in |resourceStream|, set
|
|
|
|
// 'mimeType| to the resource stream's mime type, and return RV_CONTINUE.
|
|
|
|
// To cancel loading of the resource return RV_HANDLED.
|
|
|
|
virtual RetVal HandleBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefRequest> request,
|
|
|
|
std::wstring& redirectUrl,
|
|
|
|
CefRefPtr<CefStreamReader>& resourceStream,
|
|
|
|
std::wstring& mimeType,
|
|
|
|
int loadFlags)
|
|
|
|
{
|
2009-08-21 21:43:37 +02:00
|
|
|
DWORD dwSize;
|
|
|
|
LPBYTE pBytes;
|
|
|
|
|
2008-12-02 16:48:14 +01:00
|
|
|
std::wstring url = request->GetURL();
|
2009-07-24 20:37:00 +02:00
|
|
|
if(url == L"http://tests/request") {
|
|
|
|
// Show the request contents
|
2009-08-21 04:14:47 +02:00
|
|
|
std::wstring dump;
|
|
|
|
DumpRequestContents(request, dump);
|
2009-07-24 20:37:00 +02:00
|
|
|
resourceStream = CefStreamReader::CreateForData(
|
2009-08-21 04:14:47 +02:00
|
|
|
(void*)dump.c_str(), dump.size() * sizeof(wchar_t));
|
2009-07-24 20:37:00 +02:00
|
|
|
mimeType = L"text/plain";
|
2009-08-21 21:43:37 +02:00
|
|
|
} else if(url == L"http://tests/uiapp") {
|
|
|
|
// Show the uiapp contents
|
|
|
|
if(LoadBinaryResource(IDS_UIPLUGIN, dwSize, pBytes)) {
|
|
|
|
resourceStream = CefStreamReader::CreateForHandler(
|
|
|
|
new ClientReadHandler(pBytes, dwSize));
|
|
|
|
mimeType = L"text/html";
|
|
|
|
}
|
|
|
|
} else if(wcsstr(url.c_str(), L"/logo.gif") != NULL) {
|
2008-12-02 16:48:14 +01:00
|
|
|
// Any time we find "logo.gif" in the URL substitute in our own image
|
|
|
|
if(LoadBinaryResource(IDS_LOGO, dwSize, pBytes)) {
|
2009-08-21 19:41:09 +02:00
|
|
|
resourceStream = CefStreamReader::CreateForHandler(
|
|
|
|
new ClientReadHandler(pBytes, dwSize));
|
2008-12-02 16:48:14 +01:00
|
|
|
mimeType = L"image/jpg";
|
|
|
|
}
|
2009-08-21 21:43:37 +02:00
|
|
|
} else if(wcsstr(url.c_str(), L"/logoball.png") != NULL) {
|
|
|
|
// Load the "logoball.png" image resource.
|
|
|
|
if(LoadBinaryResource(IDS_LOGOBALL, dwSize, pBytes)) {
|
|
|
|
resourceStream = CefStreamReader::CreateForHandler(
|
|
|
|
new ClientReadHandler(pBytes, dwSize));
|
|
|
|
mimeType = L"image/png";
|
|
|
|
}
|
2008-12-02 16:48:14 +01:00
|
|
|
}
|
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Event called before a context menu is displayed. To cancel display of the
|
|
|
|
// default context menu return RV_HANDLED.
|
|
|
|
virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
|
|
|
|
const MenuInfo& menuInfo)
|
|
|
|
{
|
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Event called to optionally override the default text for a context menu
|
|
|
|
// item. |label| contains the default text and may be modified to substitute
|
|
|
|
// alternate text. The return value is currently ignored.
|
|
|
|
virtual RetVal HandleGetMenuLabel(CefRefPtr<CefBrowser> browser,
|
|
|
|
MenuId menuId, std::wstring& label)
|
|
|
|
{
|
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Event called when an option is selected from the default context menu.
|
|
|
|
// Return RV_HANDLED to cancel default handling of the action.
|
|
|
|
virtual RetVal HandleMenuAction(CefRefPtr<CefBrowser> browser,
|
|
|
|
MenuId menuId)
|
|
|
|
{
|
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Event called to format print headers and footers. |printInfo| contains
|
|
|
|
// platform-specific information about the printer context. |url| is the
|
|
|
|
// URL if the currently printing page, |title| is the title of the currently
|
|
|
|
// printing page, |currentPage| is the current page number and |maxPages| is
|
|
|
|
// the total number of pages. Six default header locations are provided
|
|
|
|
// by the implementation: top left, top center, top right, bottom left,
|
|
|
|
// bottom center and bottom right. To use one of these default locations
|
|
|
|
// just assign a string to the appropriate variable. To draw the header
|
|
|
|
// and footer yourself return RV_HANDLED. Otherwise, populate the approprate
|
|
|
|
// variables and return RV_CONTINUE.
|
|
|
|
virtual RetVal HandlePrintHeaderFooter(CefRefPtr<CefBrowser> browser,
|
2009-05-28 02:31:21 +02:00
|
|
|
CefRefPtr<CefFrame> frame,
|
2008-12-02 16:48:14 +01:00
|
|
|
CefPrintInfo& printInfo,
|
|
|
|
const std::wstring& url,
|
|
|
|
const std::wstring& title,
|
|
|
|
int currentPage, int maxPages,
|
|
|
|
std::wstring& topLeft,
|
|
|
|
std::wstring& topCenter,
|
|
|
|
std::wstring& topRight,
|
|
|
|
std::wstring& bottomLeft,
|
|
|
|
std::wstring& bottomCenter,
|
|
|
|
std::wstring& bottomRight)
|
|
|
|
{
|
|
|
|
// Place the page title at top left
|
|
|
|
topLeft = title;
|
|
|
|
// Place the page URL at top right
|
|
|
|
topRight = url;
|
|
|
|
|
|
|
|
// Place "Page X of Y" at bottom center
|
|
|
|
std::wstringstream strstream;
|
|
|
|
strstream << L"Page " << currentPage << L" of " << maxPages;
|
|
|
|
bottomCenter = strstream.str();
|
|
|
|
|
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run a JS alert message. Return RV_CONTINUE to display the default alert
|
|
|
|
// or RV_HANDLED if you displayed a custom alert.
|
|
|
|
virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser,
|
2009-05-28 02:31:21 +02:00
|
|
|
CefRefPtr<CefFrame> frame,
|
2009-07-24 21:11:01 +02:00
|
|
|
const std::wstring& message)
|
|
|
|
{
|
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2008-12-02 16:48:14 +01:00
|
|
|
// Run a JS confirm request. Return RV_CONTINUE to display the default alert
|
|
|
|
// or RV_HANDLED if you displayed a custom alert. If you handled the alert
|
|
|
|
// set |retval| to true if the user accepted the confirmation.
|
|
|
|
virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser,
|
2009-05-28 02:31:21 +02:00
|
|
|
CefRefPtr<CefFrame> frame,
|
2009-07-24 21:11:01 +02:00
|
|
|
const std::wstring& message, bool& retval)
|
|
|
|
{
|
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2008-12-02 16:48:14 +01:00
|
|
|
// Run a JS prompt request. Return RV_CONTINUE to display the default prompt
|
|
|
|
// or RV_HANDLED if you displayed a custom prompt. If you handled the prompt
|
|
|
|
// set |retval| to true if the user accepted the prompt and request and
|
|
|
|
// |result| to the resulting value.
|
|
|
|
virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser,
|
2009-05-28 02:31:21 +02:00
|
|
|
CefRefPtr<CefFrame> frame,
|
2009-07-24 21:11:01 +02:00
|
|
|
const std::wstring& message,
|
|
|
|
const std::wstring& defaultValue,
|
|
|
|
bool& retval,
|
2008-12-02 16:48:14 +01:00
|
|
|
std::wstring& result)
|
|
|
|
{
|
2009-07-24 21:11:01 +02:00
|
|
|
return RV_CONTINUE;
|
2008-12-02 16:48:14 +01:00
|
|
|
}
|
|
|
|
|
2009-03-08 03:26:16 +01:00
|
|
|
// Called just before a window is closed. The return value is currently
|
|
|
|
// ignored.
|
|
|
|
virtual RetVal HandleBeforeWindowClose(CefRefPtr<CefBrowser> browser)
|
|
|
|
{
|
|
|
|
if(m_BrowserHwnd == browser->GetWindowHandle())
|
|
|
|
{
|
|
|
|
// Free the browser pointer so that the browser can be destroyed
|
|
|
|
m_Browser = NULL;
|
|
|
|
}
|
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called when the browser component is about to loose focus. For instance,
|
|
|
|
// if focus was on the last HTML element and the user pressed the TAB key.
|
|
|
|
// The return value is currently ignored.
|
|
|
|
virtual RetVal HandleTakeFocus(CefRefPtr<CefBrowser> browser, bool reverse)
|
|
|
|
{
|
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2009-05-28 02:31:21 +02:00
|
|
|
// Event called for binding to a frame's JavaScript global object. The
|
|
|
|
// return value is currently ignored.
|
|
|
|
virtual RetVal HandleJSBinding(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefV8Value> object)
|
|
|
|
{
|
2009-08-21 19:41:09 +02:00
|
|
|
// Add the V8 bindings.
|
|
|
|
InitBindingTest(browser, frame, object);
|
2009-08-21 21:43:37 +02:00
|
|
|
|
|
|
|
// Add the UI app V8 bindings.
|
|
|
|
InitUIBindingTest(browser, frame, object);
|
2009-05-28 02:31:21 +02:00
|
|
|
|
|
|
|
return RV_HANDLED;
|
|
|
|
}
|
|
|
|
|
2009-06-16 15:52:35 +02:00
|
|
|
// Called when the browser component is requesting focus. |isWidget| will be
|
|
|
|
// true if the focus is requested for a child widget of the browser window.
|
|
|
|
// Return RV_CONTINUE to allow the focus to be set or RV_HANDLED to cancel
|
|
|
|
// setting the focus.
|
|
|
|
virtual RetVal HandleSetFocus(CefRefPtr<CefBrowser> browser,
|
|
|
|
bool isWidget)
|
|
|
|
{
|
|
|
|
return RV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2008-12-02 16:48:14 +01:00
|
|
|
// Retrieve the current navigation state flags
|
|
|
|
void GetNavState(bool &isLoading, bool &canGoBack, bool &canGoForward)
|
|
|
|
{
|
|
|
|
Lock();
|
|
|
|
isLoading = m_bLoading;
|
|
|
|
canGoBack = m_bCanGoBack;
|
|
|
|
canGoForward = m_bCanGoForward;
|
|
|
|
Unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetMainHwnd(HWND hwnd)
|
|
|
|
{
|
|
|
|
Lock();
|
|
|
|
m_MainHwnd = hwnd;
|
|
|
|
Unlock();
|
|
|
|
}
|
2009-08-21 21:43:37 +02:00
|
|
|
HWND GetMainHwnd() { return m_MainHwnd; }
|
2008-12-02 16:48:14 +01:00
|
|
|
|
|
|
|
void SetEditHwnd(HWND hwnd)
|
|
|
|
{
|
|
|
|
Lock();
|
|
|
|
m_EditHwnd = hwnd;
|
|
|
|
Unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefBrowser> GetBrowser()
|
|
|
|
{
|
|
|
|
return m_Browser;
|
|
|
|
}
|
|
|
|
|
|
|
|
HWND GetBrowserHwnd()
|
|
|
|
{
|
|
|
|
return m_BrowserHwnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// The child browser window
|
|
|
|
CefRefPtr<CefBrowser> m_Browser;
|
|
|
|
|
|
|
|
// The main frame window handle
|
|
|
|
HWND m_MainHwnd;
|
|
|
|
|
|
|
|
// The child browser window handle
|
|
|
|
HWND m_BrowserHwnd;
|
|
|
|
|
|
|
|
// The edit window handle
|
|
|
|
HWND m_EditHwnd;
|
|
|
|
|
|
|
|
// True if the page is currently loading
|
|
|
|
bool m_bLoading;
|
|
|
|
// True if the user can navigate backwards
|
|
|
|
bool m_bCanGoBack;
|
|
|
|
// True if the user can navigate forwards
|
|
|
|
bool m_bCanGoForward;
|
|
|
|
};
|
|
|
|
|
2009-08-21 21:43:37 +02:00
|
|
|
// global handler instance
|
|
|
|
CefRefPtr<ClientHandler> g_handler;
|
|
|
|
|
|
|
|
CefRefPtr<CefBrowser> AppGetBrowser()
|
|
|
|
{
|
|
|
|
if(!g_handler.get())
|
|
|
|
return NULL;
|
|
|
|
return g_handler->GetBrowser();
|
|
|
|
}
|
|
|
|
|
|
|
|
HWND AppGetMainHwnd()
|
|
|
|
{
|
|
|
|
if(!g_handler.get())
|
|
|
|
return NULL;
|
|
|
|
return g_handler->GetMainHwnd();
|
|
|
|
}
|
|
|
|
|
2008-12-02 16:48:14 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
|
|
|
|
//
|
|
|
|
// PURPOSE: Processes messages for the main window.
|
|
|
|
//
|
|
|
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
static HWND backWnd = NULL, forwardWnd = NULL, reloadWnd = NULL,
|
|
|
|
stopWnd = NULL, editWnd = NULL;
|
|
|
|
static WNDPROC editWndOldProc = NULL;
|
|
|
|
|
|
|
|
int wmId, wmEvent;
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
if(hWnd == editWnd)
|
|
|
|
{
|
|
|
|
// Callback for the edit window
|
2009-07-24 21:11:01 +02:00
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_CHAR:
|
2009-08-21 21:43:37 +02:00
|
|
|
if (wParam == VK_RETURN && g_handler.get())
|
2009-07-24 21:11:01 +02:00
|
|
|
{
|
|
|
|
// When the user hits the enter key load the URL
|
2009-08-21 21:43:37 +02:00
|
|
|
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
|
2009-07-24 21:11:01 +02:00
|
|
|
wchar_t strPtr[MAX_URL_LENGTH] = {0};
|
|
|
|
*((LPWORD)strPtr) = MAX_URL_LENGTH;
|
|
|
|
LRESULT strLen = SendMessage(hWnd, EM_GETLINE, 0, (LPARAM)strPtr);
|
|
|
|
if (strLen > 0) {
|
|
|
|
strPtr[strLen] = 0;
|
|
|
|
browser->GetMainFrame()->LoadURL(strPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-02 16:48:14 +01:00
|
|
|
return (LRESULT)CallWindowProc(editWndOldProc, hWnd, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Callback for the main window
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_CREATE:
|
|
|
|
{
|
|
|
|
// Create the single static handler class instance
|
2009-08-21 21:43:37 +02:00
|
|
|
g_handler = new ClientHandler();
|
|
|
|
g_handler->SetMainHwnd(hWnd);
|
2008-12-02 16:48:14 +01:00
|
|
|
|
|
|
|
// Create the child windows used for navigation
|
|
|
|
RECT rect;
|
2009-07-24 21:11:01 +02:00
|
|
|
int x = 0;
|
|
|
|
|
2008-12-02 16:48:14 +01:00
|
|
|
GetClientRect(hWnd, &rect);
|
2009-07-24 21:11:01 +02:00
|
|
|
|
|
|
|
backWnd = CreateWindow(L"BUTTON", L"Back",
|
|
|
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
|
|
|
| WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
|
|
|
|
hWnd, (HMENU) IDC_NAV_BACK, hInst, 0);
|
|
|
|
x += BUTTON_WIDTH;
|
|
|
|
|
|
|
|
forwardWnd = CreateWindow(L"BUTTON", L"Forward",
|
|
|
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
|
|
|
| WS_DISABLED, x, 0, BUTTON_WIDTH,
|
|
|
|
URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_FORWARD,
|
|
|
|
hInst, 0);
|
|
|
|
x += BUTTON_WIDTH;
|
|
|
|
|
|
|
|
reloadWnd = CreateWindow(L"BUTTON", L"Reload",
|
|
|
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
|
|
|
| WS_DISABLED, x, 0, BUTTON_WIDTH,
|
|
|
|
URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_RELOAD,
|
|
|
|
hInst, 0);
|
|
|
|
x += BUTTON_WIDTH;
|
|
|
|
|
|
|
|
stopWnd = CreateWindow(L"BUTTON", L"Stop",
|
|
|
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
|
|
|
| WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
|
|
|
|
hWnd, (HMENU) IDC_NAV_STOP, hInst, 0);
|
|
|
|
x += BUTTON_WIDTH;
|
|
|
|
|
|
|
|
editWnd = CreateWindow(L"EDIT", 0,
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT |
|
|
|
|
ES_AUTOVSCROLL | ES_AUTOHSCROLL| WS_DISABLED,
|
|
|
|
x, 0, rect.right - BUTTON_WIDTH * 4,
|
|
|
|
URLBAR_HEIGHT, hWnd, 0, hInst, 0);
|
|
|
|
|
|
|
|
// Assign the edit window's WNDPROC to this function so that we can
|
|
|
|
// capture the enter key
|
|
|
|
editWndOldProc =
|
|
|
|
reinterpret_cast<WNDPROC>(GetWindowLongPtr(editWnd, GWLP_WNDPROC));
|
2008-12-02 16:48:14 +01:00
|
|
|
SetWindowLongPtr(editWnd, GWLP_WNDPROC,
|
|
|
|
reinterpret_cast<LONG_PTR>(WndProc));
|
2009-08-21 21:43:37 +02:00
|
|
|
g_handler->SetEditHwnd(editWnd);
|
2008-12-02 16:48:14 +01:00
|
|
|
|
|
|
|
rect.top += URLBAR_HEIGHT;
|
|
|
|
|
|
|
|
CefWindowInfo info;
|
|
|
|
|
|
|
|
// Initialize window info to the defaults for a child window
|
|
|
|
info.SetAsChild(hWnd, rect);
|
|
|
|
|
|
|
|
// Creat the new child child browser window
|
|
|
|
CefBrowser::CreateBrowser(info, false,
|
2009-08-21 21:43:37 +02:00
|
|
|
static_cast<CefRefPtr<CefHandler>>(g_handler),
|
2008-12-02 16:48:14 +01:00
|
|
|
L"http://www.google.com");
|
|
|
|
|
|
|
|
// Start the timer that will be used to update child window state
|
2008-12-14 05:49:18 +01:00
|
|
|
SetTimer(hWnd, 1, 250, NULL);
|
2008-12-02 16:48:14 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WM_TIMER:
|
2009-08-21 21:43:37 +02:00
|
|
|
if(g_handler.get() && g_handler->GetBrowserHwnd())
|
2008-12-02 16:48:14 +01:00
|
|
|
{
|
|
|
|
// Retrieve the current navigation state
|
|
|
|
bool isLoading, canGoBack, canGoForward;
|
2009-08-21 21:43:37 +02:00
|
|
|
g_handler->GetNavState(isLoading, canGoBack, canGoForward);
|
2008-12-02 16:48:14 +01:00
|
|
|
|
|
|
|
// Update the status of child windows
|
|
|
|
EnableWindow(editWnd, TRUE);
|
|
|
|
EnableWindow(backWnd, canGoBack);
|
|
|
|
EnableWindow(forwardWnd, canGoForward);
|
|
|
|
EnableWindow(reloadWnd, !isLoading);
|
|
|
|
EnableWindow(stopWnd, isLoading);
|
|
|
|
}
|
2009-03-08 03:26:16 +01:00
|
|
|
return 0;
|
2008-12-02 16:48:14 +01:00
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
{
|
|
|
|
CefRefPtr<CefBrowser> browser;
|
2009-08-21 21:43:37 +02:00
|
|
|
if(g_handler.get())
|
|
|
|
browser = g_handler->GetBrowser();
|
2008-12-02 16:48:14 +01:00
|
|
|
|
|
|
|
wmId = LOWORD(wParam);
|
|
|
|
wmEvent = HIWORD(wParam);
|
|
|
|
// Parse the menu selections:
|
|
|
|
switch (wmId)
|
|
|
|
{
|
|
|
|
case IDM_ABOUT:
|
|
|
|
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
|
|
|
|
return 0;
|
|
|
|
case IDM_EXIT:
|
|
|
|
DestroyWindow(hWnd);
|
|
|
|
return 0;
|
|
|
|
case IDC_NAV_BACK: // Back button
|
|
|
|
if(browser.get())
|
|
|
|
browser->GoBack();
|
|
|
|
return 0;
|
|
|
|
case IDC_NAV_FORWARD: // Forward button
|
|
|
|
if(browser.get())
|
|
|
|
browser->GoForward();
|
|
|
|
return 0;
|
|
|
|
case IDC_NAV_RELOAD: // Reload button
|
|
|
|
if(browser.get())
|
|
|
|
browser->Reload();
|
|
|
|
return 0;
|
|
|
|
case IDC_NAV_STOP: // Stop button
|
|
|
|
if(browser.get())
|
|
|
|
browser->StopLoad();
|
|
|
|
return 0;
|
2009-05-28 02:31:21 +02:00
|
|
|
case ID_TESTS_JAVASCRIPT_HANDLER: // Test the V8 function handler
|
2008-12-02 16:48:14 +01:00
|
|
|
if(browser.get())
|
2009-08-21 19:41:09 +02:00
|
|
|
RunBindingTest(browser);
|
2009-05-28 02:31:21 +02:00
|
|
|
return 0;
|
|
|
|
case ID_TESTS_JAVASCRIPT_HANDLER2: // Test the V8 extension handler
|
|
|
|
if(browser.get())
|
2009-08-21 19:41:09 +02:00
|
|
|
RunExtensionTest(browser);
|
2008-12-02 16:48:14 +01:00
|
|
|
return 0;
|
2009-01-29 18:48:16 +01:00
|
|
|
case ID_TESTS_JAVASCRIPT_EXECUTE: // Test execution of javascript
|
|
|
|
if(browser.get())
|
|
|
|
{
|
2009-05-28 02:31:21 +02:00
|
|
|
browser->GetMainFrame()->ExecuteJavaScript(
|
|
|
|
L"alert('JavaScript execute works!');",
|
|
|
|
L"about:blank", 0);
|
2009-01-29 18:48:16 +01:00
|
|
|
}
|
|
|
|
return 0;
|
2009-05-28 02:31:21 +02:00
|
|
|
case ID_TESTS_PLUGIN: // Test the custom plugin
|
2008-12-14 05:49:18 +01:00
|
|
|
if(browser.get())
|
2009-08-21 19:41:09 +02:00
|
|
|
RunPluginTest(browser);
|
2009-01-29 18:48:16 +01:00
|
|
|
return 0;
|
2009-03-06 20:20:44 +01:00
|
|
|
case ID_TESTS_POPUP: // Test a popup window
|
|
|
|
if(browser.get())
|
|
|
|
{
|
2009-05-28 02:31:21 +02:00
|
|
|
browser->GetMainFrame()->ExecuteJavaScript(
|
|
|
|
L"window.open('http://www.google.com');",
|
|
|
|
L"about:blank", 0);
|
2009-03-06 20:20:44 +01:00
|
|
|
}
|
|
|
|
return 0;
|
2009-07-24 20:37:00 +02:00
|
|
|
case ID_TESTS_REQUEST: // Test a request
|
|
|
|
if(browser.get())
|
|
|
|
{
|
|
|
|
// Create a new request
|
|
|
|
CefRefPtr<CefRequest> request(CefRequest::CreateRequest());
|
|
|
|
|
|
|
|
// Set the request URL
|
|
|
|
request->SetURL(L"http://tests/request");
|
|
|
|
|
|
|
|
// Add post data to the request. The correct method and content-
|
|
|
|
// type headers will be set by CEF.
|
|
|
|
CefRefPtr<CefPostDataElement> postDataElement(
|
|
|
|
CefPostDataElement::CreatePostDataElement());
|
|
|
|
std::string data = "arg1=val1&arg2=val2";
|
|
|
|
postDataElement->SetToBytes(data.length(), data.c_str());
|
|
|
|
CefRefPtr<CefPostData> postData(CefPostData::CreatePostData());
|
|
|
|
postData->AddElement(postDataElement);
|
|
|
|
request->SetPostData(postData);
|
|
|
|
|
|
|
|
// Add a custom header
|
|
|
|
CefRequest::HeaderMap headerMap;
|
|
|
|
headerMap.insert(
|
|
|
|
std::make_pair(L"X-My-Header", L"My Header Value"));
|
|
|
|
request->SetHeaderMap(headerMap);
|
|
|
|
|
|
|
|
// Load the request
|
|
|
|
browser->GetMainFrame()->LoadRequest(request);
|
|
|
|
}
|
|
|
|
return 0;
|
2009-08-21 04:14:47 +02:00
|
|
|
case ID_TESTS_SCHEME_HANDLER: // Test the scheme handler
|
|
|
|
if(browser.get())
|
2009-08-21 19:41:09 +02:00
|
|
|
RunSchemeTest(browser);
|
2009-08-21 04:14:47 +02:00
|
|
|
return 0;
|
2009-08-21 21:43:37 +02:00
|
|
|
case ID_TESTS_UIAPP: // Test the UI app
|
|
|
|
if(browser.get())
|
|
|
|
RunUIPluginTest(browser);
|
|
|
|
return 0;
|
2008-12-02 16:48:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_PAINT:
|
|
|
|
hdc = BeginPaint(hWnd, &ps);
|
|
|
|
EndPaint(hWnd, &ps);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WM_SETFOCUS:
|
2009-08-21 21:43:37 +02:00
|
|
|
if(g_handler.get() && g_handler->GetBrowserHwnd())
|
2008-12-02 16:48:14 +01:00
|
|
|
{
|
|
|
|
// Pass focus to the browser window
|
2009-08-21 21:43:37 +02:00
|
|
|
PostMessage(g_handler->GetBrowserHwnd(), WM_SETFOCUS, wParam, NULL);
|
2008-12-02 16:48:14 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WM_SIZE:
|
2009-08-21 21:43:37 +02:00
|
|
|
if(g_handler.get() && g_handler->GetBrowserHwnd())
|
2008-12-02 16:48:14 +01:00
|
|
|
{
|
|
|
|
// Resize the browser window and address bar to match the new frame
|
|
|
|
// window size
|
|
|
|
RECT rect;
|
|
|
|
GetClientRect(hWnd, &rect);
|
|
|
|
rect.top += URLBAR_HEIGHT;
|
|
|
|
|
|
|
|
int urloffset = rect.left + BUTTON_WIDTH * 4;
|
|
|
|
|
|
|
|
HDWP hdwp = BeginDeferWindowPos(1);
|
|
|
|
hdwp = DeferWindowPos(hdwp, editWnd, NULL, urloffset,
|
|
|
|
0, rect.right - urloffset, URLBAR_HEIGHT, SWP_NOZORDER);
|
2009-08-21 21:43:37 +02:00
|
|
|
hdwp = DeferWindowPos(hdwp, g_handler->GetBrowserHwnd(), NULL,
|
2008-12-02 16:48:14 +01:00
|
|
|
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
|
|
|
|
SWP_NOZORDER);
|
|
|
|
EndDeferWindowPos(hdwp);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-07-24 21:11:01 +02:00
|
|
|
case WM_ERASEBKGND:
|
2009-08-21 21:43:37 +02:00
|
|
|
if(g_handler.get() && g_handler->GetBrowserHwnd())
|
2009-07-24 21:11:01 +02:00
|
|
|
{
|
|
|
|
// Dont erase the background if the browser window has been loaded
|
|
|
|
// (this avoids flashing)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
2008-12-02 16:48:14 +01:00
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
// The frame window has exited
|
|
|
|
KillTimer(hWnd, 1);
|
|
|
|
PostQuitMessage(0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Message handler for about box.
|
|
|
|
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(lParam);
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
return (INT_PTR)TRUE;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
|
|
|
{
|
|
|
|
EndDialog(hDlg, LOWORD(wParam));
|
|
|
|
return (INT_PTR)TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return (INT_PTR)FALSE;
|
|
|
|
}
|