473,394 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Thru code Determine if PC has Large/Small Fonts set

Joe
Hi

trying to write some code to determine if user has large/small fonts set on
PC
thought this would work but it didn't

Any suggestions???
Thanks
Graphics g = Graphics.FromHwnd(this.Handle);

if(g.DpiX == 96)

sFonts = "System running Small/Normal Fonts";

else if (g.DpiX == 120)

sFonts = "System running Large Fonts";

Dec 19 '06 #1
8 3215
Hello Joe,

Check the HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Hardware Profiles\0001\Software\Fonts\LogPixels
value
Jtrying to write some code to determine if user has large/small fonts
Jset on
JPC
Jthought this would work but it didn't
JAny suggestions???
J>
---
WBR,
Michael Nemtseva [C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
Dec 19 '06 #2
"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
Dec 19 '06 #3
Joe
Hi

I think I am losing my mind :-)

I checked where you suggested and also some others
They are all set to 96 even though thru Properties->Apperance I have large
fonts selected??????
HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\AppliedDPI
HKLM\SYSTEM\CurrentControlSet\Hardware
Profiles\Current\Software\Fonts\LogPixels
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI\LogPixels

"Michael Nemtsev" <ne*****@msn.comwrote in message
news:17***************************@msnews.microsof t.com...
Hello Joe,

Check the HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Hardware
Profiles\0001\Software\Fonts\LogPixels value
Jtrying to write some code to determine if user has large/small fonts
Jset on
JPC
Jthought this would work but it didn't
JAny suggestions???
J---
WBR,
Michael Nemtseva [C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


Dec 19 '06 #4
Hello Joe,

Have u pressed the Refresh in regedit after u applied new DPI?
In my environment I got new value

JHi
J>
JI think I am losing my mind :-)
J>
JI checked where you suggested and also some others
JThey are all set to 96 even though thru Properties->Apperance I have
Jlarge
Jfonts selected??????
JHKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\AppliedDPI
JHKLM\SYSTEM\CurrentControlSet\Hardware
JProfiles\Current\Software\Fonts\LogPixels
JHKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI\LogPixels
J>
J"Michael Nemtsev" <ne*****@msn.comwrote in message
Jnews:17***************************@msnews.microso ft.com...
J>
>Hello Joe,

Check the HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Hardware
Profiles\0001\Software\Fonts\LogPixels value

Jtrying to write some code to determine if user has large/small
fonts
Jset on
JPC
Jthought this would work but it didn't
JAny suggestions???
J---
WBR,
Michael Nemtseva [C# MVP] :: blog: http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high
and we miss it, but that it is too low and we reach it" (c)
Michelangelo
---
WBR,
Michael Nemtseva [C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
Dec 19 '06 #5
Joe
Hi

Thanks for the info.

I was basically only do this to help with debugging some UI issues in
development.
If a user is having a UI problem I just wanted this info to eliminate it
from consideration.

The interesting issue is that - I run the code on 2 machine 1 with Large
Fonts and another with small Fonts
The code I wrote and also looking at the registry are all set to 96 ???? I
am confused

I set fonts thru Properties->Appearance

Thanks
"Lucian Wischik" <lu***@wischik.comwrote in message
news:7c********************************@4ax.com...
"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

Dec 19 '06 #6
Joe
I tried it on 2 machines and even rebooted and it didn't change
I am running XP sp2

Weird :-)

"Michael Nemtsev" <ne*****@msn.comwrote in message
news:17***************************@msnews.microsof t.com...
Hello Joe,

Have u pressed the Refresh in regedit after u applied new DPI?
In my environment I got new value

JHi
JJI think I am losing my mind :-)
JJI checked where you suggested and also some others
JThey are all set to 96 even though thru Properties->Apperance I have
Jlarge
Jfonts selected??????
JHKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\AppliedDPI
JHKLM\SYSTEM\CurrentControlSet\Hardware
JProfiles\Current\Software\Fonts\LogPixels
JHKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI\LogPixels
JJ"Michael Nemtsev" <ne*****@msn.comwrote in message
Jnews:17***************************@msnews.microso ft.com...
J>
>>Hello Joe,

Check the HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Hardware
Profiles\0001\Software\Fonts\LogPixels value

Jtrying to write some code to determine if user has large/small
fonts
Jset on
JPC
Jthought this would work but it didn't
JAny suggestions???
J---
WBR,
Michael Nemtseva [C# MVP] :: blog: http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high
and we miss it, but that it is too low and we reach it" (c)
Michelangelo
---
WBR,
Michael Nemtseva [C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


Dec 19 '06 #7
"Joe" <hc******@yahoo.comwrote:
>I set fonts thru Properties->Appearance
Ah. Properties>Appearance doesn't change the DPI. It only picks a
larger font size for certain UI elements. So these UI elements will be
larger while everything else remains the same.

Settings>Advanced>DPISetting will chang the DPI. It alters the scale
of EVERYTHING in the UI (fonts, scrollbars, buttons, ...). This DPI is
what's used by windows to scale dialogs.

--
Lucian
Dec 19 '06 #8
"Lucian Wischik" <lu***@wischik.comwrote in message
news:7c********************************@4ax.com...
(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.
That's not exactly true. For small enough integer values (where "small
enough" depends on the size of the mantissa), they can be represented
exactly as floating point, and are.

120 is stored internally as 120. If you know in advance that you are
dealing with floating point values that can be and are represented exactly,
you can do a direct comparison.

Another alternative to comparing within an epsilon value is to simply round
the float to the nearest integer. Of course, this only works when the
numbers you are comparing are supposed to be integers in the first place.
:)

Not that this has anything to do with this thread, but I just had to stick
my nose in. :)

Pete
Dec 20 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
13
by: Xah Lee | last post by:
the Journey of Foreign Characters thru Internet Xah Lee, 20051101 There's a bunch of confusions about the display of non-ascii characters such as the bullet "•". These confusions are...
9
by: Adam | last post by:
Can someone please help!! I am trying to figure out what a font is? Assume I am working with a fixed font say Courier 10 point font Question 1: What does this mean 10 point font Question 2:...
4
by: John Baro | last post by:
I need to determine which fonts are human readable. Webdings, wingdings etc.. are not. Is there any easy way to accomplish this? Cheers JB
2
by: | last post by:
I have a breakpoint in an aspx page that I'm using to try to trap some code to see what's going on. I'm translating a page that is working in a traditional ASP page, which takes several session...
5
by: Alex Glass | last post by:
I have created a winforms application and I designed it with the normal display settings, (96DPI) however, when I set the font settings to 120 DPI, my application text labels look all messed up. ...
0
by: sonali_reddy123 | last post by:
Hi, I have a problem regarding the Large fonts use for the apppliaction. I have a VB.NET application whose UI I have designed with settings of my computer having Small Fonts. But as I have...
9
by: William Cruz | last post by:
How can I access these unicode symbols & show them thru my application. Thanks. http://www.unicode.org/charts/PDF/U2200.pdf William Cruz *** Sent via Developersdex...
2
by: Luc | last post by:
I saw a few posts on this newsgroup about it but nothing to help me resolve this problem: We designed a window in .NET on a platform using small fonts (120 ppp). But this window will run on...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.