I'm trying to figure out the font DPI size on the target Windows machine and modify our app's font so that it appears the same size as it would if the target machine had the same dpi as the dev machine. (So a larger Target DPI would mean we'd make our fonts smaller than at dev time).
I'm wondering if there are any problems with the solution below and specifically whether LOGPIXELSX=88 is correct.
Background
I resize all controls and fonts on our forms to match the current Windows screen resolution. However, if someone has their Font DPI set higher, we need to account for that and make the font smaller (so it ends up being the right size on the screen). Our fonts are already quite large (especially since we resize them w/ screen res). The extra size from the higher DPI makes the text too large.
My solution so far From what I can tell, if we use the GetDeviceCaps as below and then get the CurrentFontDPI and do this: (Ignoring the font size modification due to the new screen resolution):
NewFontSize=CurrentFontSize * (DevelopmentDPI/CurrentFontDPI)
Function CurrentFontDPI
Dim hwnd, hDC, logPix, r As Long
Dim LOGPIXELSX=88
hwnd = GetDesktopWindow()
hDC = GetDC(hwnd)
logPix = GetDeviceCaps(hDC,LOGPIXELSX )
r = ReleaseDC(hwnd, hDC)
CurrentFontDPI= logPix
end Function
FYI, the above code is part of a larger routine at "a related SO Question][1]. I left out the rest of the code b/c it seemed to at least one error (it had NewFont=OldFont * (NewDPI-OldDPI) which would give you zero height fontsize if the DPI hadn't changed)
[1]: http://www.BungalowSoftware.com test