"Joe" <hc******@yahoo.comwrote:
>trying to write some code to determine if user has large/small fonts set on
PC. Thought this would work but it didn't
It does work more or less. e.g. The following code works perfectly:
Graphics g = Graphics.FromHwnd(this.Handle);
MessageBox.Show(g.DpiX.ToString());
Your code had two problems:
(1) Graphics.DpiX is a float. You can't really test whether a float is
== to another number, not in any language. That's because a float like
"120" will internally be stored as something like 119.9999999997. You
should only ever test whether a float is within a certain margin of
the other number. People usually call that margin "epsilon".
(2) Font size isn't restricted to 96 and 120. It's a continuum. On my
system, for example, font size is set to 144. (Hey, I'm getting old
and my eyesight's fading!)
Basically, if your program depends on knowing whether it's small or
large fonts, then it probably has bad design. You might try explaining
what you're trying to achieve by testing Dpi, and others might be able
to assist.
--
Lucian