how to design forms that support any DPI setting

E

Emby

I recently released an app that looks and works fine under any desktop
resolution setting, but have discovered that if a user's machine has a DPI
setting above the standard 96 DPI, my forms are distorted and some controls
are even clipped, that is, off-screen. This is especially painful when the
clipped control is the close button for a modal dialog, and extremely so if
it's a dialog from which I've removed the "close box".

One can certainly argue the merits of such a design decision, but why
doesn't WinForms under VS8 (2005) properly handle the video settings of the
client machine.

To really handle this properly, it looks like I'd have to modify
autogenerated code in the form.Designer.cs (or .vb) file, which is where
controls are positioned and sized when they are instantiated on the form.
Sure, I could patch things up in the OnLoad override, but strictly speaking,
I think the code handling this issue belongs with the constructors and
initializers in the InitializeComponent routine.

Or have I missed something? Anyone have some guidance or opins on this?

Ah, OK, so I've read the help topic titled "Automatic Scaling in Windows
Forms", and it says that "Font" autoscaling is the default. I find it hard
to understand why the default behavior would clip controls under different
DPI conditions.

Can anyone please explain this to me ??

Thanks
 
E

Emby

Just to experiment a bit, I created a simple VB 2005 win app: 1 small form,
with some text and a close button in the lower right corner of the form, no
close box. Native resolution is 1600x1200 at 96 DPI. I created one EXE with
Font autoscaling and another with DPI autoscaling.

Then I just changed my DPI to 120 and rebooted. Well, the BOTH EXE versions
are missing the close button. in fact I can double-click on the title bar
(which has no system menu, min, max or close boxes), and this maximizes the
form ... and the Close button is STILL no where to be seen! What's up with
that ??

I can close the form with Alt-F4, but where the heck did the button go ?

Perplexed ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top