Browse Source

win32 rect fix

Henrique Santiago 10 years ago
parent
commit
dc409fe76c
1 changed files with 27 additions and 18 deletions
  1. 27
    18
      src/framework/win32platform.cpp

+ 27
- 18
src/framework/win32platform.cpp View File

@@ -111,19 +111,20 @@ bool Platform::createWindow(int x, int y, int width, int height, int minWidth, i
111 111
     win32.minHeight = minHeight;
112 112
     win32.maximized = maximized;
113 113
 
114
-    //AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle);
115
-
116
-    win32.window = CreateWindowExA(dwExStyle,		// Extended Style For The Window
117
-                                   win32.appName.c_str(),       // Class Name
118
-                                   win32.appName.c_str(),       // Window Title
119
-                                   dwStyle,		// Required Window Style
120
-                                   x,                   // Window X Position
121
-                                   y,                   // Window Y Position
122
-                                   width,               // Calculate Window Width
123
-                                   height,              // Calculate Window Height
124
-                                   NULL,		// No Parent Window
125
-                                   NULL,		// No Menu
126
-                                   win32.instance,	// Instance
114
+    RECT windowRect = {x, y, x + width, y + height};
115
+    AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle);
116
+
117
+    win32.window = CreateWindowExA(dwExStyle,                           // Extended Style For The Window
118
+                                   win32.appName.c_str(),               // Class Name
119
+                                   win32.appName.c_str(),               // Window Title
120
+                                   dwStyle,                             // Required Window Style
121
+                                   windowRect.left,                     // Window X Position
122
+                                   windowRect.top,                      // Window Y Position
123
+                                   windowRect.right - windowRect.left,  // Calculate Window Width
124
+                                   windowRect.bottom - windowRect.top,  // Calculate Window Height
125
+                                   NULL,		                // No Parent Window
126
+                                   NULL,		                // No Menu
127
+                                   win32.instance,                      // Instance
127 128
                                    NULL);
128 129
 
129 130
     if(!win32.window) {
@@ -314,6 +315,16 @@ int Platform::getWindowHeight()
314 315
     return win32.height;
315 316
 }
316 317
 
318
+int Platform::getDisplayWidth()
319
+{
320
+    return GetSystemMetrics(SM_CXSCREEN);
321
+}
322
+
323
+int Platform::getDisplayHeight()
324
+{
325
+    return GetSystemMetrics(SM_CYSCREEN);
326
+}
327
+
317 328
 bool Platform::isWindowMaximized()
318 329
 {
319 330
     return win32.maximized;
@@ -344,12 +355,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
344 355
             minMax->ptMinTrackSize.y = win32.minHeight;
345 356
             break;
346 357
         }
347
-    case WM_MOVING:
348
-    case WM_SIZING:
358
+    case WM_MOVE:
349 359
         {
350
-            RECT *rect = (RECT*)lParam;
351
-            win32.x = rect->left;
352
-            win32.y = rect->top;
360
+            win32.x = LOWORD(lParam);
361
+            win32.y = HIWORD(lParam);
353 362
             break;
354 363
         }
355 364
     case WM_SIZE:

Loading…
Cancel
Save