#include "win32/Win32Window.h"
+#include <sstream>
+
Key VirtualKeyCodeToKey(WPARAM key, LPARAM flags)
{
switch (key)
{
destroy();
- mParentClassName = name;
- mChildClassName = name + "Child";
+ // Use a new window class name for ever window to ensure that a new window can be created
+ // even if the last one was not properly destroyed
+ static size_t windowIdx = 0;
+ std::ostringstream nameStream;
+ nameStream << name << "_" << windowIdx++;
+
+ mParentClassName = nameStream.str();
+ mChildClassName = mParentClassName + "_Child";
+
+ // Work around compile error from not defining "UNICODE" while Chromium does
+ const LPSTR idcArrow = MAKEINTRESOURCEA(32512);
WNDCLASSEXA parentWindowClass = { 0 };
parentWindowClass.cbSize = sizeof(WNDCLASSEXA);
parentWindowClass.cbWndExtra = 0;
parentWindowClass.hInstance = GetModuleHandle(NULL);
parentWindowClass.hIcon = NULL;
- parentWindowClass.hCursor = LoadCursorA(NULL, IDC_ARROW);
+ parentWindowClass.hCursor = LoadCursorA(NULL, idcArrow);
parentWindowClass.hbrBackground = 0;
parentWindowClass.lpszMenuName = NULL;
parentWindowClass.lpszClassName = mParentClassName.c_str();
childWindowClass.cbWndExtra = 0;
childWindowClass.hInstance = GetModuleHandle(NULL);
childWindowClass.hIcon = NULL;
- childWindowClass.hCursor = LoadCursorA(NULL, IDC_ARROW);
+ childWindowClass.hCursor = LoadCursorA(NULL, idcArrow);
childWindowClass.hbrBackground = 0;
childWindowClass.lpszMenuName = NULL;
childWindowClass.lpszClassName = mChildClassName.c_str();
return false;
}
- DWORD parentStyle = WS_VISIBLE | WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU;
+ DWORD parentStyle = WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU;
DWORD parentExtendedStyle = WS_EX_APPWINDOW;
RECT sizeRect = { 0, 0, width, height };
sizeRect.right - sizeRect.left, sizeRect.bottom - sizeRect.top, NULL, NULL,
GetModuleHandle(NULL), this);
- mNativeWindow = CreateWindowExA(0, mChildClassName.c_str(), name.c_str(), WS_VISIBLE | WS_CHILD, 0, 0, width, height,
+ mNativeWindow = CreateWindowExA(0, mChildClassName.c_str(), name.c_str(), WS_CHILD, 0, 0, width, height,
mParentWindow, NULL, GetModuleHandle(NULL), this);
mNativeDisplay = GetDC(mNativeWindow);
return true;
}
-bool Win32Window::setVisible(bool isVisible)
+void Win32Window::setVisible(bool isVisible)
{
int flag = (isVisible ? SW_SHOW : SW_HIDE);
- return (ShowWindow(mNativeWindow, flag) == TRUE) &&
- (ShowWindow(mParentWindow, flag) == TRUE);
+ ShowWindow(mParentWindow, flag);
+ ShowWindow(mNativeWindow, flag);
}
void Win32Window::pushEvent(Event event)