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
 
Back
Top