Designing applications independent of System Font Size

I'm facing a general problem while designing any application. The application is designed in Small Fonts and runs fine when the target system is running Small Fonts (96 dpi)... However, the controls are misplaced under a system running Large Fonts (120 dpi).

I want some way of detecting the system DPI setting in C# (Important) ... so that I can display a warning on runtime. If there is a way to set it through C# programatically, it would be great... I've checked out MSDN, they don't have anything on it.
LVL 12
mcv22Asked:
Who is Participating?
 
natejacobsCommented:
Try setting the Form's 'AutoScale' property to False.  I haven't used this property myself, but I understand it's used for exactly this scenario.

From MSDN:
"You can use this property to allow your form and its controls to automatically adjust based on changes in the font. This can be useful in applications where the font might increase or decrease based on the language specified for use by Windows.

To obtain the size the form will auto scale to, use the AutoScaleBaseSize property. If you want to determine the size the form will auto scale to based on a specific font, use the GetAutoScaleSize method."
0
 
mcv22Author Commented:
Hi, I tried that ....... didn't work... any other solution?
0
 
natejacobsCommented:
I looked around for techniques to get the DPI but only found samples in C++.  If you go to CodeProject.com and search for 'DPI' you'll see a number of examples.
Maybe you could use a C++ DLL in your project to make the calls?
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
mcv22Author Commented:
Yeah, I have checked code project earlier and did find what you found. How can a C++ dll be used with my project. Could you elaborate or get me a link.
0
 
natejacobsCommented:
Apologies, mcv, but you just found the end of my knowledge!

Suggestion:  Post to the C++ forum, linking to this question.

Regards,

Nate
0
 
mcv22Author Commented:
The question remains open ... I would prefer a straight forward C# code, since I am not really used to importing DLLs made using C++
0
 
mcv22Author Commented:
Okay, AutoScale set to true and AutoScaleBaseSize checking worked. It seems AutoScaling helps only text elements, which wasnt of much help to me cause my application involves realtime graphics. So I just pop up an error message if the System Font Size is not 96 dpi.

This should help others facing this problem:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/winforms12102002.asp

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.