I want to run my application on 96dpi, no matter what the dpi size from Windows is set to. It is possible ?
' Edit ' I found that using the Scale() method and resizing the font will almost do the trick.
public class MyForm : Form
{
private static bool ScaleDetected = false;
const float DPI = 80F;
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (!ScaleDetected)
{
Graphics g = e.Graphics;
float factorX = DPI / g.DpiX;
float factorY = DPI / g.DpiY;
SizeF newSize = new SizeF(factorX, factorY);
AutoScaleDimensions = newSize;
AutoScaleMode = AutoScaleMode.Dpi;
Scale(newSize);
Font = new Font(Font.FontFamily, Font.Size * factorX);
ScaleDetected = true;
}
}
}
However when using this 'trick' in a MDI application using Janus Controls, the main form is resized, but for some other forms, the scaling + changed font are not applied.