1

The problem I'm having is I'm losing toolbars when they're dragged from 4k to a standard def. monitor on a 200% scaled desktop (they JUST VANISH) (Derived from CMFCToolbar). This looks a bit like a MFC bug as I'm not handling the dragging process, however on app. startup it does check windows are on the desktop somewhere by doing this -

int width =  GetSystemMetrics(SM_CXVIRTUALSCREEN);
int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);

which gives me 11520 (incorrect) x 2160 (correct).

I've got a 4K monitor on the left and 1080p monitor on the right. Desktop scaling is 200%

With per monitor scaling I get 5760 x 2160. Which is plausible; the app is on the 4k monitor.

(With no DPI support I get 5760 x 1080. Shouldn't it be telling me my main monitor is 1920 across?)

So (1) Is there a bug in these API's telling me my desktop size? (2) Do I need to delve around in MFC source to see why it can;t handle dragging from a high def to a sd screen?

bobobobo
  • 64,917
  • 62
  • 258
  • 363
craker
  • 67
  • 9
  • I am getting the same issue, it seems to me that `GetSystemMetrics(SM_CXVIRTUALSCREEN)` doesn't work for very large resolutions – bobobobo Sep 17 '21 at 19:37

1 Answers1

2

As wrote in documentation for GetSystemMetrics function:

This API is not DPI aware, and should not be used if the calling thread is per-monitor DPI aware. For the DPI-aware version of this API, see GetSystemMetricsForDPI. For more information on DPI awareness, see the Windows High DPI documentation.

https://learn.microsoft.com/uk-ua/windows/win32/api/winuser/nf-winuser-getsystemmetrics

Volodymyr
  • 29
  • 4