Windows has a setting that many users are oblivious to, but which is intended to make the screen more readable on high resolution small physical size devices. In different places it is called various things: “large fonts” or “high DPI” (dots per inch). The actual setting is determinable by:
iHDC = getdc (0)
ixdpi = GetDeviceCaps(iHDC, LOGPIXELSX)
iydpi = GetDeviceCaps(iHDC, LOGPIXELSY)
and the value is referred to as “logical DPI”. A standard screen, like the one I use on a desktop PC appears to be set to a figure of 96 DPI. In all versions of Windows one can alter this setting. After a bit of experience, I have concluded that 96 DPI is present in around 95+% of cases, the 120 DPI setting is next commonest, although it is found infrequently and normally only on fancy desktop-substitute laptops. The other settings – especially the custom settings – are even rarer. My guess is that 120 DPI (125% of 96) is the first offering, and where 96 won’t do, 120 is good enough, so that most users don’t get any further. The User Experience Guidelines suggest testing programs at 120 AND 144 as well as the standard settings.
On the whole, Clearwin seems to work (by design?) regardless of the screen resolution and the DPI settings on the target computer. This appears to be because everything in a Clearwin format window is set out according to character cells (which one can see using %gd) based on the average width of a lower case character counting the whole alphabet. With DPI settings other than 96, this sometimes leads to things not lining up vertically, but that is about as bad as it gets. A simple problem of borders not appearing for %rf boxes is also related to the font scaling. As the system font has different metrics in XP and 7, ergo why the layout of some dialogs changes between the windows versions.
Where it is important, however, is there one has fixed-size bitmaps interspersed with text, so that as the character size changes, a variety of problems arise: these range from simple non-alignment, through aesthetic issues of the bitmap looking too small, right up to scrambled windows. Under XP, I have made my programs deal with this issue by finding the dpi setting, and if possible, loading the appropriately-sized bitmap from my RESOURCES, and refusing to run if the dpi setting is one I can’t cope with (usually custom settings). Bitmaps include icons and toolbar buttons, as well as GIF, JPEG and BMP images that one may use in format windows.
I regarded this as bad enough, but in Windows 7, something has changed. The DPI setting is returned as in XP, until one reaches the magic value of 144 (or more), at which point the setting returned by GetDeviceCaps goes back to 96, and the screen is scaled by the appropriate percentage automatically by Windows. The Windows 7 setting is causing me a problem. Vista apparently does something similar.
The solution to this is apparently to declare that the program is “DPI aware”. There are two ways of declaring this, the first of which is to call system subroutine and a second is to make an entry in the application manifest. Manifests are something of a mystery to me, and I suspect for most programmers. The system subroutine is a LOGICAL*4 function called SetProcess DPIAware. If you are compiling under XP, then attempting to invoke this subroutine will fail as it is not present in the user32.dll. However, if you compile under Vista/7 and link although the routine is found and incorporated, and running this programme under XP will cause a variety of mischief, so I have found that you must use GET_OS_VER@ and not call SetProcessDPIAware unless the major version number is 6 or more.
At least this goes back to being not particularly more complicated than it was under XP – although that, to my mind, was over elaborate.
Eddie