Getting the DPI setting?

  • Thread starter Thread starter JezB
  • Start date Start date
J

JezB

Running my windows forms on screens set to 133 DPI has some odd effects
(scroll-bars suddenly appearing because objects overflow their containers).
Setting the AutoScaleMode to dpi doesn't seem to fix the problems either. Is
it possible to evaluate the DPI setting within the code and make the
relevant adjustments to your measurements ? C# if possible please :)
 
JezB said:
Running my windows forms on screens set to 133 DPI has some odd effects
(scroll-bars suddenly appearing because objects overflow their
containers). Setting the AutoScaleMode to dpi doesn't seem to fix the
problems either. Is it possible to evaluate the DPI setting within the
code and make the relevant adjustments to your measurements ? C# if
possible please :)

The code below can be used inside a form to determine the current DPI
settings:

\\\
using (Graphics g = this.CreateGraphics())
{
x = g.DpiX;
y = g.DpiY;
}
///

In addition to the code above check out the form's 'AutoScale' property.
 
Hi Herfried,

Is there anyway the form can maintain the looks on different DPIs?

Thank You,
Vish
 

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

Back
Top