I am using GetDeviceCaps to retrieve the physical screen size of my monitor,
however it is returning 320mm by 150 mm. I know for a fact my screen is 320mm
by 240mm when I measure it with a ruler. My resolution is set to 800 x 600 at
96 DPI in Windows display properties. What's going on?
Here is the code I am using to retrieve the information:
i_HorzSize = GetDeviceCaps(hdc,HORZSIZE); = 320mm
i_VertSize = GetDeviceCaps(hdc,VERTSIZE); = 150mm ????
lx_PxPerInch = GetDeviceCaps(hdc,LOGPIXELSX); = 96
ly_PxPerInch = GetDeviceCaps(hdc,LOGPIXELSY); = 96
I believe Windows makes the following calculations to calculate the HORZSIXE
and the VERTSIZE:
Horiz size (mm)=25.4 x (Horizontal Resolution (Pixels)/Logical PixelsX
(Dots/inch)
Vert size (mm)=25.4 x (Vertical Resolution (Pixels)/Logical PixelsY
(Dots/inch)
Why is Windows returning a Horizontal size of 150? when it is physically
240mm?
--
Best regards
Robert
This issue was addressed by Scott McPhillips and myself in a response to
your "LOMETRIC not precise" post. Put simply, the values that Windows
reports are not accurate.
> Here is the code I am using to retrieve the information:
>
> i_HorzSize = GetDeviceCaps(hdc,HORZSIZE); = 320mm
> i_VertSize = GetDeviceCaps(hdc,VERTSIZE); = 150mm ????
>
> lx_PxPerInch = GetDeviceCaps(hdc,LOGPIXELSX); = 96
> ly_PxPerInch = GetDeviceCaps(hdc,LOGPIXELSY); = 96
>
> I believe Windows makes the following calculations to calculate the
> HORZSIXE and the VERTSIZE:
>
> Horiz size (mm)=25.4 x (Horizontal Resolution (Pixels)/Logical PixelsX
> (Dots/inch)
> Vert size (mm)=25.4 x (Vertical Resolution (Pixels)/Logical PixelsY
> (Dots/inch)
Why do you believe that? It is certainly not consistent with the figures you
report (nor with what I see on my computer).
> Why is Windows returning a Horizontal size of 150? when it is
> physically 240mm?
At a guess, I would say it is because there is no agreed protocol for a
monitor to report to the operating system how big it is.
--
John Carson
Because I believe every thing I read at first glance... Windows *assumes*
that your video display resolution is 96DPI when 96DPI is set in Windows
display properties.
So if the functions below often return wrong values, what use are they in
our programs?
i_HorzSize = GetDeviceCaps(hdc,HORZSIZE);
i_VertSize = GetDeviceCaps(hdc,VERTSIZE);
I find myself not even using them in any of the mapping modes....
WOW I find the learning curve is hard when it comes to seeing the whole
picture of mapping modes, text point size, resolutions within Windows.
John Get back!
--
Best regards
Robert
They are no use at all. Windows simply does *not* support programming that
attempts to specify the actual physical dimensions of graphics on a monitor.
It does support it on a printer, where GetDeviceCaps(hdc,LOGPIXELSX) and
GetDeviceCaps(hdc,LOGPIXELSY) give you the *actual physical* DPI.
Basically, monitors have historically offered too low a resolution to be
able to give both measurement-accurate displays and legibility. Thus a
choice was made to go for legibility and to give up measurement-accuracy. In
particular, the power was placed in the user's hands to decide how big "1
inch" is on their display by controlling screen resolution and the
LOGPIXELSX and LOGPIXELSY values. If "1 inch" needs to be physically 2
inches in order for the user to read the screen, then the user has the power
to make it that way.
In general, as far as the programmer is concerned, 1 horizontal inch is the
number of pixels given by GetDeviceCaps(hdc,LOGPIXELSX). How big this
actually is on screen is up to the user to decide, not the programmer.
If there is some specialized application that needs a measurement-accurate
monitor display, then you will have to get your ruler out and measure the
display rather than relying on the HORZSIZE and the VERTSIZE values. More
generally, you could supply a dialog box and ask the user to measure their
display and enter the appropriate values in the dialog box. I can't speak
for other types of applications, but almost no desktop application requires
a measurement-accurate monitor display.
If you are asking wouldn't it be better if the HORZSIZE and the VERTSIZE
parameters did not exist, since they give misleading information, then the
answer is yes.
--
John Carson
Correct. Until not very long ago, 96 and 120 were the ONLY possible DPI
values for a video display. Today, Windows allows finer adjustment, but it
isn't commonly used.
>So if the functions below often return wrong values, what use are they in
>our programs?
>
>i_HorzSize = GetDeviceCaps(hdc,HORZSIZE);
>i_VertSize = GetDeviceCaps(hdc,VERTSIZE);
>
>I find myself not even using them in any of the mapping modes....
Right. They are useful ONLY on a printer. Those values are strictly
decorative in a video display.
If you need something approaching real inches, you have to display a "fake"
ruler on the screen, have the user measure it with a real-world ruler, and
enter the size. From that, you can get real-world inches. However, it
usually isn't worth the trouble.
>WOW I find the learning curve is hard when it comes to seeing the whole
>picture of mapping modes, text point size, resolutions within Windows.
There isn't that much to it. Most people don't use the metric and English
mapping modes, because they don't have any real world meaning. Usually,
what you want to use is pixels, or a percentage of the window width. The
mapping modes do let you do that.
--
- Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.
And yes John! thats exactly what I was asking, because silly me!, I thought
that Windows solidly based itslelf on HORZSIZE and the VERTSIZE for its
extents calculations.
You guys have been great!
--
Best regards
Robert