Change window positioning and sizing for Windows (Fixes #212)

This commit is contained in:
saschawillems 2016-07-28 23:07:04 +02:00
parent 175b15da51
commit 4ed547a916

View file

@ -958,20 +958,10 @@ HWND VulkanExampleBase::setupWindow(HINSTANCE hinstance, WNDPROC wndproc)
} }
RECT windowRect; RECT windowRect;
if (fullscreen) windowRect.left = 0L;
{ windowRect.top = 0L;
windowRect.left = (long)0; windowRect.right = fullscreen ? (long)screenWidth : (long)width;
windowRect.right = (long)screenWidth; windowRect.bottom = fullscreen ? (long)screenHeight : (long)height;
windowRect.top = (long)0;
windowRect.bottom = (long)screenHeight;
}
else
{
windowRect.left = (long)screenWidth / 2 - width / 2;
windowRect.right = (long)width;
windowRect.top = (long)screenHeight / 2 - height / 2;
windowRect.bottom = (long)height;
}
AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle); AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle);
@ -980,15 +970,23 @@ HWND VulkanExampleBase::setupWindow(HINSTANCE hinstance, WNDPROC wndproc)
name.c_str(), name.c_str(),
windowTitle.c_str(), windowTitle.c_str(),
dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
windowRect.left, 0,
windowRect.top, 0,
windowRect.right, windowRect.right - windowRect.left,
windowRect.bottom, windowRect.bottom - windowRect.top,
NULL, NULL,
NULL, NULL,
hinstance, hinstance,
NULL); NULL);
if (!fullscreen)
{
// Center on screen
uint32_t x = (GetSystemMetrics(SM_CXSCREEN) - windowRect.right) / 2;
uint32_t y = (GetSystemMetrics(SM_CYSCREEN) - windowRect.bottom) / 2;
SetWindowPos(window, 0, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
if (!window) if (!window)
{ {
printf("Could not create window!\n"); printf("Could not create window!\n");