2015-01-27 01:03:25 +01:00
|
|
|
// Copyright (c) 2015 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.
|
|
|
|
|
2016-11-18 00:52:42 +01:00
|
|
|
#include "tests/cefclient/browser/temp_window_win.h"
|
2015-01-27 01:03:25 +01:00
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
#include <windows.h>
|
|
|
|
|
2015-01-27 01:03:25 +01:00
|
|
|
#include "include/base/cef_logging.h"
|
|
|
|
|
|
|
|
namespace client {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
const wchar_t kWndClass[] = L"Client_TempWindow";
|
|
|
|
|
|
|
|
// Create the temp window.
|
|
|
|
HWND CreateTempWindow() {
|
|
|
|
HINSTANCE hInstance = ::GetModuleHandle(NULL);
|
|
|
|
|
|
|
|
WNDCLASSEX wc = {0};
|
|
|
|
wc.cbSize = sizeof(wc);
|
|
|
|
wc.lpfnWndProc = DefWindowProc;
|
|
|
|
wc.hInstance = hInstance;
|
|
|
|
wc.lpszClassName = kWndClass;
|
|
|
|
RegisterClassEx(&wc);
|
|
|
|
|
|
|
|
// Create a 1x1 pixel hidden window.
|
2017-05-17 11:29:28 +02:00
|
|
|
return CreateWindow(kWndClass, 0, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, 0, 0,
|
|
|
|
1, 1, NULL, NULL, hInstance, NULL);
|
2015-01-27 01:03:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TempWindowWin* g_temp_window = NULL;
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
TempWindowWin::TempWindowWin() : hwnd_(NULL) {
|
2015-01-27 01:03:25 +01:00
|
|
|
DCHECK(!g_temp_window);
|
|
|
|
g_temp_window = this;
|
|
|
|
|
|
|
|
hwnd_ = CreateTempWindow();
|
|
|
|
CHECK(hwnd_);
|
|
|
|
}
|
|
|
|
|
|
|
|
TempWindowWin::~TempWindowWin() {
|
|
|
|
g_temp_window = NULL;
|
|
|
|
DCHECK(hwnd_);
|
|
|
|
DestroyWindow(hwnd_);
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2015-01-29 21:53:53 +01:00
|
|
|
CefWindowHandle TempWindowWin::GetWindowHandle() {
|
2015-01-27 01:03:25 +01:00
|
|
|
DCHECK(g_temp_window);
|
|
|
|
return g_temp_window->hwnd_;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace client
|