Why is there two different functions GetDpiForSystem and GetDpiForWindow in WinApi?

1.3k Views Asked by At

Could anyone give some examples when window DPI can differ from system one? Maybe users can somehow specify from outside an application in which DPI it should run. Or maybe it's something else.

1

There are 1 best solutions below

2
Adrian Mole On

Software can change the DPI Awareness setting(s) for windows created by a specific thread (using the SetThreadDpiAwarenessContext function), in which case a call to GetDpiForWindow for such windows will then give a (potentially) different value than a call to GetDpiForSystem.

Further, even within a given thread (or process), one can change the DPI awareness with a call to the aforementioned function, create a new window, then revert to the previous settings and create another window. Then, those two windows will have (possibly) different DPI values from each other (depending on whether or not the executable has been built with DPI awareness enabled).