Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29274 Discussions

Can I get the screen size from the registry?

michael_green
Beginner
503 Views
Hi,
I need a means to determine how many pixels per centimetre any screen displays - centimetres in the real world that is.
I need this for scaling text shown on maps on screen so that, regardless of how much the user zooms in or out, the text displays at the correct size relative to the other features on the map, and I need to relate this to the real world because the maps will ultimately be printed on paper. Thus, if the user specifies 12 point text for the map on paper, the point size loaded in my T_LOGFONT will be something different from 12, but related to it by the zoom factor, and the scaling factor I am looking for.
My guess is that I can get this from the registry - but where and how? Please can anybody help?
With many thanks in advance,
Mike
0 Kudos
1 Reply
Jugoslav_Dujic
Valued Contributor II
503 Views
I don't follow you 100%, but here are my 2c...
There's NO way you can retrieve exact monitor dpi settings via an API or registry (and I'm rather positive about that). For the start, Windows does not know monitor size in general -- generic "Plug and Play monitor" driver works just fine for most uses. About the best way is to ask user somewhere in your application's configuration, and then do some simple calculations (e.g. make a dpi table for various screen diagonal/resolution/font sizes, measuring a "referent" one using a ruler on your monitor :-) )You probably do know about the following APIs, but I'd mention them anyway:
GetDeviceCaps(GetDC(NULL), LOGPIXELSY) -- always returns 96 (72 for large fonts?)
GetSystemMetrics(SM_CYSCREEN) --vertical resolutionof primary display monitor (see also SM_CYVIRTUALSCREEN if you want to allow for multiple-monitor configurations)
nFontHeight = -MulDiv(12, dpiVertical, 72) -- formula for 12-point font in CreateFont[Indirect] for device resolution of dpiVertical
Hope this helps,
Jugoslav
0 Kudos
Reply