From 4d55bbe4ff07da9e816daa2711a3ca2a7ac07e40 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Sun, 30 Jun 2013 20:51:24 +0200 Subject: [PATCH] Fixed windows bigger than the desktop not appearing on Windows (#215) --- src/SFML/Window/Win32/WindowImplWin32.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index e98cd037..47003465 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -103,8 +103,8 @@ m_surrogate (0) // Compute position and size HDC screenDC = GetDC(NULL); - int left = (GetDeviceCaps(screenDC, HORZRES) - mode.width) / 2; - int top = (GetDeviceCaps(screenDC, VERTRES) - mode.height) / 2; + int left = (GetDeviceCaps(screenDC, HORZRES) - static_cast(mode.width)) / 2; + int top = (GetDeviceCaps(screenDC, VERTRES) - static_cast(mode.height)) / 2; int width = mode.width; int height = mode.height; ReleaseDC(NULL, screenDC); @@ -142,6 +142,10 @@ m_surrogate (0) m_handle = CreateWindowA(classNameA, title.toAnsiString().c_str(), win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this); } + // By default, the OS limits the size of the window the the desktop size, + // we have to resize it after creation to apply the real size + setSize(Vector2u(mode.width, mode.height)); + // Switch to fullscreen if requested if (fullscreen) switchToFullscreen(mode); @@ -489,6 +493,21 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam) break; } + // The system request the min/max window size and position + case WM_GETMINMAXINFO : + { + // We override the returned information to remove the default limit + // (the OS doesn't allow windows bigger than the desktop by default) + MINMAXINFO* info = reinterpret_cast(lParam); + info->ptMaxPosition.x = 50000; + info->ptMaxPosition.y = 50000; + info->ptMaxSize.x = 50000; + info->ptMaxSize.y = 50000; + info->ptMaxTrackSize.x = 50000; + info->ptMaxTrackSize.y = 50000; + break; + } + // Gain focus event case WM_SETFOCUS : {