]> git.sesse.net Git - casparcg/blobdiff - dependencies64/cef/windows/tests/cefclient/browser/temp_window_win.cc
Upgrade CEF to 3.3029.1611.g44e39a8 / Chromium 58.0.3029.81.
[casparcg] / dependencies64 / cef / windows / tests / cefclient / browser / temp_window_win.cc
diff --git a/dependencies64/cef/windows/tests/cefclient/browser/temp_window_win.cc b/dependencies64/cef/windows/tests/cefclient/browser/temp_window_win.cc
new file mode 100644 (file)
index 0000000..8d62dd4
--- /dev/null
@@ -0,0 +1,60 @@
+// 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.
+
+#include "tests/cefclient/browser/temp_window_win.h"
+
+#include <windows.h>
+
+#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.
+  return CreateWindow(kWndClass, 0,
+                      WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
+                      0, 0, 1, 1,
+                      NULL, NULL, hInstance, NULL);
+}
+
+TempWindowWin* g_temp_window = NULL;
+
+}  // namespace
+
+TempWindowWin::TempWindowWin()
+    : hwnd_(NULL) {
+  DCHECK(!g_temp_window);
+  g_temp_window = this;
+
+  hwnd_ = CreateTempWindow();
+  CHECK(hwnd_);
+}
+
+TempWindowWin::~TempWindowWin() {
+  g_temp_window = NULL;
+  DCHECK(hwnd_);
+  DestroyWindow(hwnd_);
+}
+
+// static
+CefWindowHandle TempWindowWin::GetWindowHandle() {
+  DCHECK(g_temp_window);
+  return g_temp_window->hwnd_;
+}
+
+}  // namespace client