473,395 Members | 2,006 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,395 software developers and data experts.

DPI Settings

Hi -

I have a VB.NET application (for Win2K and later), and I'd like to ensure
that it displays properly regardless of how the user has set his DPI Setting
on his system.

1. What is the best way to detect the user's DPI setting?

I found 2 registry keys, but which is the right one to check (or is there a
better way)? The 2 keys I found are:

HKCU\Control Panel\Desktop\WindowsMetrics\AppliedDPI
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI\LogPixels

I'm guessing, if checking the registry is the best approach, that the
LogPixels value is the one to check. (I've read somewhere that AppliedDPI
may not be present for all Windows versions.)

2. What is the best way to code my application to accommodate different DPI
settings?

I could 'brute-force' it by coditionally setting top/right/bottom/left for
each control, depending on the result from my question 1 (above). That
would seem to be a lot of work, would expand code size, and might affect
performance. (And it doesn't address possible custom settings.) Is there a
better way?

How are all of you handling this issue?

Thanks for your help.

- Jeff

Nov 21 '05 #1
3 11864
Nak
Hi Jeff,

I think you can use the graphics object for the form or control,

Dim pop As Graphics = Me.CreateGraphics
Console.WriteLine(pop.DpiX & " - " & pop.DpiY)

Nick.

"Jeff" <je*********@eNetPortals.com> wrote in message
news:SX*****************@newsread2.news.atl.earthl ink.net...
Hi -

I have a VB.NET application (for Win2K and later), and I'd like to ensure
that it displays properly regardless of how the user has set his DPI
Setting
on his system.

1. What is the best way to detect the user's DPI setting?

I found 2 registry keys, but which is the right one to check (or is there
a
better way)? The 2 keys I found are:

HKCU\Control Panel\Desktop\WindowsMetrics\AppliedDPI
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI\LogPixels

I'm guessing, if checking the registry is the best approach, that the
LogPixels value is the one to check. (I've read somewhere that AppliedDPI
may not be present for all Windows versions.)

2. What is the best way to code my application to accommodate different
DPI
settings?

I could 'brute-force' it by coditionally setting top/right/bottom/left for
each control, depending on the result from my question 1 (above). That
would seem to be a lot of work, would expand code size, and might affect
performance. (And it doesn't address possible custom settings.) Is there
a
better way?

How are all of you handling this issue?

Thanks for your help.

- Jeff

Nov 21 '05 #2
Thanks Nick -

As I understand your suggestion, it's an alternate way to detect the dpi
setting. Why/how is it better than checking the registry settings? And
again, how should I code my application to accommodate different DPI
settings?

- Jeff
"Nak" <a@a.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Jeff,

I think you can use the graphics object for the form or control,

Dim pop As Graphics = Me.CreateGraphics
Console.WriteLine(pop.DpiX & " - " & pop.DpiY)

Nick.

"Jeff" <je*********@eNetPortals.com> wrote in message
news:SX*****************@newsread2.news.atl.earthl ink.net...
Hi -

I have a VB.NET application (for Win2K and later), and I'd like to ensure that it displays properly regardless of how the user has set his DPI
Setting
on his system.

1. What is the best way to detect the user's DPI setting?

I found 2 registry keys, but which is the right one to check (or is there a
better way)? The 2 keys I found are:

HKCU\Control Panel\Desktop\WindowsMetrics\AppliedDPI
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI\LogPixels

I'm guessing, if checking the registry is the best approach, that the
LogPixels value is the one to check. (I've read somewhere that AppliedDPI may not be present for all Windows versions.)

2. What is the best way to code my application to accommodate different
DPI
settings?

I could 'brute-force' it by coditionally setting top/right/bottom/left for each control, depending on the result from my question 1 (above). That
would seem to be a lot of work, would expand code size, and might affect
performance. (And it doesn't address possible custom settings.) Is there a
better way?

How are all of you handling this issue?

Thanks for your help.

- Jeff


Nov 21 '05 #3
Nak
Hi Jeff,
As I understand your suggestion, it's an alternate way to detect the dpi
setting. Why/how is it better than checking the registry settings? And
again, how should I code my application to accommodate different DPI
settings?


I believe that the graphics context for a form would have to be made at
the current systems DPI settings by default. There isn't any particular
reason why it should be better than checking the registry but I believe it
to always be better to use another method other than a hard coded registry
key. I'm sure there must also be an API available (which is always the
preferred choice).

http://www.mentalis.org/apilist/GetDeviceCaps.shtml
^Apparently *all* versions of Windows support this!

http://msdn.microsoft.com/library/de...highdpiapp.asp
^An MSDN article on the subject!

As to how you would program an application to accommodate a different
DPI, I have no idea! Though the above MSDN link shows you how. It's
interesting you should ask this question because I have never thought of it
before, and I certainly remember applications like Dreamweaver being
tempramental in the past due to high DPI incompatability.

Anyway, I hope this information is helpful!

Nick.
Nov 21 '05 #4

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

Similar topics

6
by: GS | last post by:
Hi, There is reference about accessing settings file in VB.NET but nothing about C#. How do I read settings in application settings file with C#? Thanks, G
2
by: GS | last post by:
How do I use My.Settings equivalent in C#? Below is part of MSDN documentation about accessing settings file. I wrote C# console application using VS 2005 and .NET 2.0 and would like to use new...
10
by: Paul Cheetham | last post by:
Hi, I am developing an application that needs to store some machine-specific settings. The application is going to be published on the network in order to keep the clients on the latest version....
10
by: Chris Dunaway | last post by:
I have an .exe console project and a class library project as part of a solution. The .exe has an App.config file and I have used the Settings page to add some Application level settings. When...
2
by: MacKris | last post by:
Hi, I'm a chemist trying to use the python script GaussSum.py with gnuplot for creating dataplots, and need some help. Whenever I try to produce a plot from the GaussSum GUI I get the error sh:...
3
by: Jon Slaughter | last post by:
I wrote an app that needed to save settings such as colors, fonts, etc... after hours of trying to use ConfigurationManager and AppSettings along with a few other things I finally found that I...
5
by: Andy | last post by:
I need to write a VB.NET WinForms app. For this purpose I need to keep some settings of the application, like many other Windows applications do. The most obvious solution is to store settings in...
0
by: =?Utf-8?B?UmljayBHbG9z?= | last post by:
For some unknown reason (user error?), I cannot get a NameValueCollection to persist in the app.config file. Unlike other settings, I cannot get the String Collection Editor GUI to allow my to...
6
by: WT | last post by:
Hello, Using VS2005. I have an assembly library that can be called from a Web site asp.net application or from a winform application. From this library I need to retrieve a path using simply a...
5
by: Rainer Queck | last post by:
Hello NG, Is it possible to share the settings of an application with a class libreary? In my case I have a application and a set of different reports (home made) put into a class library. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.