Windows 10,DPI缩放和全屏 [英] Windows 10, DPI scaling and fullscreen
问题描述
我有一个应用程序,该应用程序是Windows 8.1的PROCESS_PER_MONITOR_DPI_AWARE和Windows 10 v1703的DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2。在窗口模式下,我的窗口具有WS_OVERLAPPEDWINDOW样式,在全屏模式下,我将其切换为监视器大小的WS_POPUP。
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.
当我在同一台显示器上更改DPI时,会出现窗口-mode窗口在Windows 8.1和Windows 10 v1703上的WM_DPICHANGED消息中获取正确缩放的窗口大小。但是,当全屏显示时,Windows 8.1不会调整全屏窗口的大小(保持相同的尺寸),而Windows 10 v1703会调整大小。这意味着25dpi的2560x1440全屏窗口在Windows 8.1上为144 dpi时仍为2560x1440,但在Windows 10 v1703上将其调整为3840x2160。
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.
是这是正常情况,即保持全屏窗口大小与接收WM_GETDPISCALEDSIZE消息时应该手动执行的大小一样,该消息过去在Windows 8.1上是自动完成的?
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?
编辑:经过进一步测试,仅当窗口为全屏时,WM_GETDPISCALEDSIZE消息似乎才被发送(WS_POPUP有效,但仅当其大小与监视器相同时才显示)。因此,我什至无法覆盖此行为,对于全屏显示窗口,Windows 8.1的工作方式与Windows 10 v1703不同。
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.
推荐答案
尝试一下:
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);
}
对解决W8.1的问题是否有帮助?
Will it help to solve the problem on W8.1?
这篇关于Windows 10,DPI缩放和全屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!