1 year ago

#375152

test-img

Ashot

C# how to get changed display settings

The app uses event to get display setting change.

SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged;

When new display is added app moves to new display. Inside event listener the app calculates its new cordinates. The problem is that app still gets old display settings and uses it to draw itself on the new display.

double dpi = 1;
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd(IntPtr.Zero))
{
    dpi = g.DpiX / 96;
}

This is how the app gets DPI of the display. Here it gets old display DPI. Can you help to solve this issue. Maybe there is a way to force .Net to load display settings again?

c#

wpf

windows

display

dpi

0 Answers

Your Answer

Accepted video resources