3

I have an application which is PROCESS_PER_MONITOR_DPI_AWARE from Windows 8.1 and DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 from Windows 10 v1703. My windows have the WS_OVERLAPPEDWINDOW style when in windowed mode, and I switch them to a monitor-sized WS_POPUP when fullscreening.

When I change DPI on the same monitor, a windowed-mode window get a correctly-scaled window size in the WM_DPICHANGED message on both Windows 8.1 and Windows 10 v1703. When fullscreened however, Windows 8.1 doesn't resize a fullscreen window (it keeps the same dimensions) but Windows 10 v1703 does. This means that a 2560x1440 fullscreen window at 96 dpi stays 2560x1440 on Windows 8.1 when going to, say, 144 dpi, but gets resized to 3840x2160 on Windows 10 v1703.

Is this normal i.e. is keeping a fullscreen window the same size something I should now be manually doing when receiving the WM_GETDPISCALEDSIZE message, which just used to be done automatically on Windows 8.1?

EDIT: After further testing, the WM_GETDPISCALEDSIZE message doesn't even seem to be sent if the window is fullscreen, only if it's windowed (WS_POPUP works but only if the size isn't the same as the monitor). Therefore I can't even override this behaviour, and Windows 8.1 works different to Windows 10 v1703 for fullscreened windows.

Rajveer
  • 847
  • 11
  • 28
  • What styles do you set to make window fullscreen (other than WS_POPUP ) ? – c-smile Oct 30 '17 at 20:11
  • When going to fullscreen I set `WS_POPUP | WS_VISIBLE`, and going back to windowed I use `WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE`. – Rajveer Oct 30 '17 at 20:44
  • There seems to be contradiction in the question... You say that it stay the same size in Windows 8.1, then later, you say it used to be done automatically in Windows 8.1. – Phil1970 Oct 31 '17 at 11:01
  • No contradiction, I say "keeping a fullscreen window the same size...used to be done automatically on Windows 8.1". Windows 10 v1703 doesn't keep a fullscreen window the same size, and I want it to. – Rajveer Oct 31 '17 at 12:58

1 Answers1

0

Try this:

void ShowFullScreen(HWND hwnd)
{
  LONG exStyle = ::GetWindowLong(hwnd, GWL_EXSTYLE);
  LONG style   = ::GetWindowLong(hwnd, GWL_STYLE);

  ::SetWindowLong(hwnd, GWL_STYLE,
                        (style & ~WS_OVERLAPPEDWINDOW) | WS_POPUPWINDOW);
  ::SetWindowLong(hwnd, GWL_EXSTYLE, exStyle | WS_EX_TOPMOST);
  ::ShowWindow(hwnd, SW_SHOWMAXIMIZED);
}

Will it help to solve the problem on W8.1?

c-smile
  • 26,734
  • 7
  • 59
  • 86
  • Thanks for posting this, however this doesn't fix the issue on Windows 10. Fullscreening a window with this method still results in it being resized when changing the dpi. – Rajveer Oct 30 '17 at 20:51
  • I cannot reproduce the issue in Sciter (http://sciter.com) where I do exactly that. Relevant sample {sciter-sdk}/samples/dialogs+windows/test-window.htm -> "tool fullscreen" button. Window covers full desktop surface. – c-smile Oct 30 '17 at 21:43