How to detect desktop scaling?

Is there someway to detect what the desktop scaling is set to when starting up a MonoGame app? I’d like to handle scaling in my app manually, but I would also like to start with whatever setting the user has told their OS that their scaling preference is.

I have the dpiAware and dpiAwareness properties in my app.manifest file, and those seem to be working correctly. Ideally I’d like to be able to read a property like GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.DesktopScaling that would tell me what the user has set as their desktop scaling so I can use that as an initial value.

If there’s not a built-in way in MonoGame to do this, does anyone know I can get this value on different platforms?

I can’t give you any specifics, but I remember digging through this once. I think there’s a very obscure way to get the info through the Win32 API. If you’re only running on Windows, this shouldn’t be a problem for you. If you intent to support other operating systems, there are ways you can work around this… :slight_smile:

I found this answer, which seems to work for Windows: https://stackoverflow.com/a/5977638/3856907
That’s good enough for me for now, although I would like to have this support for Linux/Mac OS it’s a much lower priority.

Provided you can figure out how to get that information on those operating systems (if they even support such things), you can use Dependency Injection to your advantage.

Good luck!