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() {
|
2021-06-17 22:08:01 +02:00
|
|
|
HINSTANCE hInstance = ::GetModuleHandle(nullptr);
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
WNDCLASSEX wc = {0};
|
|
|
|
wc.cbSize = sizeof(wc);
|
|
|
|
wc.lpfnWndProc = DefWindowProc;
|
|
|
|
wc.hInstance = hInstance;
|
|
|
|
wc.lpszClassName = kWndClass;
|
|
|
|
RegisterClassEx(&wc);
|
|
|
|
|
|
|
|
// Create a 1x1 pixel hidden window.
|
2024-01-20 03:22:56 +01:00
|
|
|
return CreateWindow(kWndClass, nullptr, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
|
|
|
|
0, 0, 1, 1, nullptr, nullptr, hInstance, nullptr);
|
2015-01-27 01:03:25 +01:00
|
|
|
}
|
|
|
|
|
2020-01-15 15:28:12 +01:00
|
|
|
TempWindowWin* g_temp_window = nullptr;
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2021-06-17 22:08:01 +02:00
|
|
|
TempWindowWin::TempWindowWin() : hwnd_(nullptr) {
|
2015-01-27 01:03:25 +01:00
|
|
|
DCHECK(!g_temp_window);
|
|
|
|
g_temp_window = this;
|
|
|
|
|
|
|
|
hwnd_ = CreateTempWindow();
|
|
|
|
CHECK(hwnd_);
|
|
|
|
}
|
|
|
|
|
|
|
|
TempWindowWin::~TempWindowWin() {
|
2020-01-15 15:28:12 +01:00
|
|
|
g_temp_window = nullptr;
|
2015-01-27 01:03:25 +01:00
|
|
|
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
|