Просмотр исходного кода

Modified Win32 window to be centered in screen.

Sean Paul Taylor 14 лет назад
Родитель
Сommit
6561f7d058
2 измененных файлов с 5 добавлено и 1 удалено
  1. 5 0
      gameplay/src/PlatformWin32.cpp
  2. 0 1
      gameplay/src/gameplay-main-qnx.cpp

+ 5 - 0
gameplay/src/PlatformWin32.cpp

@@ -475,6 +475,11 @@ Platform* Platform::create(Game* game)
     // Get the drawing context.
     __hdc = GetDC(__hwnd);
 
+    // Center the window
+    const int screenX = (GetSystemMetrics(SM_CXSCREEN) - WINDOW_WIDTH) / 2;
+    const int screenY = (GetSystemMetrics(SM_CYSCREEN) - WINDOW_HEIGHT) / 2;
+    ::SetWindowPos(__hwnd, __hwnd, screenX, screenY, -1, -1, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
+
     // Choose pixel format. 32-bit. RGBA.
     PIXELFORMATDESCRIPTOR pfd;
     memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));

+ 0 - 1
gameplay/src/gameplay-main-qnx.cpp

@@ -4,7 +4,6 @@
 
 using namespace gameplay;
 
-
 /**
  * Main entry point.
  */