I have a Windows application with floating windows. I am running it on a multi-monitor setup (FHD, 4K). The application is marked as system-aware, so we pick the current DPI value for the primary monitor and scale according to that. After that, the OS bitmap-scales it. The application is running on Windows 10.
Now, when one of the floating windows is dragged to another monitor, the OS bitmap-scales it automatically, and it all works fine.
The problem is that we have some windows without a title bar, and we have code to move those windows by dragging from the client area of the window. When the mouse is released, we call the MoveWindow()
API to move the window to the target location. This works fine on a single monitor, but when we drop the window on a different monitor, it does not bitmap-scale, it seems to lose its drop location. The OS only seems to bitmap-scale when we drag a window by its title bar and not when it is moved programmatically.
Any ideas on how this automatic scaling can be achieved when moving a window programmatically?
CodePudding user response:
So it depends on how the window is created. I fixed it by creating the window using WS_CAPTION
style and then removing that style later. I am not sure what is does internally but it now scales correctly when it is moved to another screen either through mouse-drag or by using an API such as MoveWindow
.
::CreateWindowEx(WS_EX_PALETTEWINDOW,...,..., WS_POPUP | WS_CAPTION,...);
::SetWindowLong(hWnd, GWL_STYLE, ::GetWindowLong(hWnd, GWL_STYLE) & ~WS_CAPTION);