Handle WM_DPICHANGED in the WndProcrelease_2.934
authorJon Turney <[email protected]>
Mon, 28 Apr 2025 19:32:32 +0000 (28 20:32 +0100)
committerJon Turney <[email protected]>
Tue, 29 Apr 2025 13:10:45 +0000 (29 14:10 +0100)
Handle WM_DPICHANGED in the WndProc, where it actually gets delivered.

proppage.cc
propsheet.cc

index 2ab0339..d177f2d 100644 (file)
@@ -361,21 +361,6 @@ PropertyPage::DialogProc (UINT message, WPARAM wParam, LPARAM lParam)
                // similar delegation as with WM_MOUSEWHEEL
         return OnTimerMessage (message, wParam, lParam);
 
-      case WM_DPICHANGED:
-        {
-          // To support Per Monitor V2 DPI Awareness declared in the manifest,
-          // adjust the window size after DPI changes.
-          RECT* const prcNewWindow = (RECT*)lParam;
-          SetWindowPos(GetHWND (),
-                       NULL,
-                       prcNewWindow -> left,
-                       prcNewWindow -> top,
-                       prcNewWindow -> right - prcNewWindow -> left,
-                       prcNewWindow -> bottom - prcNewWindow -> top,
-                       SWP_NOZORDER | SWP_NOACTIVATE);
-          return TRUE;
-        }
-
       default:
         break;
     }
index faf6583..749fba1 100644 (file)
@@ -275,6 +275,21 @@ static LRESULT CALLBACK PropSheetWndProc (HWND hwnd, UINT uMsg,
         InvalidateRect(hwnd, &rect, FALSE);
       }
       break;
+
+    case WM_DPICHANGED:
+      {
+        // adjust the window size after DPI changes.
+        RECT* const prcNewWindow = (RECT*)lParam;
+        SetWindowPos(hwnd,
+                     NULL,
+                     prcNewWindow -> left,
+                     prcNewWindow -> top,
+                     prcNewWindow -> right - prcNewWindow -> left,
+                     prcNewWindow -> bottom - prcNewWindow -> top,
+                     SWP_NOZORDER | SWP_NOACTIVATE);
+        return TRUE;
+      }
+      break;
     }
 
   return CallWindowProc (psd.oldWndProc,