Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is a winform shown different on the same 4k monitor

Tags:

c#

winforms

We have a legacy .net windows forms application. We've already replaced most of it with a web application, but still use the windows forms application for administration tasks.

When this application is used on a 4k monitor, it looks really bad, and that's understandable.

But the look changes depending of other monitors on the system. The test is done on a lenovo 430 which has a 4k monitor connected via display port. The resolution on the laptop monitor is 1920/1080 and on the 4k monitor its 3840/2160. The display scaling is always 200%.

All of the following screen shots were taken on the 4k monitor.

  1. One test with both monitor active
  2. One test with second screen only
  3. One test with the notebook monitor closed (which means only one monitor available for the system)

enter image description hereenter image description hereenter image description here

I am aware that our application will not look good on 4k without changes and setting dpiAware/dpiAwareness.

But my question is: Why does the applications look change only depending on which monitors are active? And is there a way to control which "kind" of look is taken?

like image 326
Manuel Avatar asked Apr 04 '17 07:04

Manuel


People also ask

Why does my 4K monitor not look 4K?

Sometimes, it's because the monitor doesn't have a built-in scaling process, which stretches pixels to fit the screen real estate. Scaling is how much everything on the screen should be enlarged when measured in pixels.

Can you notice the difference in a 4K monitor?

Sure, things aren't going to be as crisp, but if you're getting a 24-inch or 27-inch monitor, you probably won't notice the difference, unless you're looking at the two monitors side-by-side.

Are 4K monitors actually 4K?

What Does a 4K Monitor Provide? The term “4K” refers to the next generational leap in display resolution beyond HD (also known as 1080p). While HD content is 1920 x 1080 pixels in size, 4K delivers four times as many pixels at 3840 x 2160.

What is scaling on a 4K monitor?

You can select '100%', '125%', '150%', '175%', '200%', '225%', '250%', '300%' or '350%'. These scaling options, shown below, are found under 'Settings – System – Display'. They can be accessed via 'Settings' on the start menu or alternatively by right clicking on the desktop and selecting 'Display settings'.


1 Answers

Maybe you are aware of this, but it was not mentioned before:

There are 3 kinds of applications:

  • Not DPI aware
  • System DPI aware
  • Per monitor DPI aware

Details here: https://msdn.microsoft.com/de-de/library/windows/desktop/dn469266(v=vs.85).aspx

You can set the DPI-awareness on your application in app.config:

<appSettings>
    <add key="EnableWindowsFormsHighDpiAutoResizing" value="false" />
</appSettings>

and app.manifest:

<application xmlns="urn:schemas-microsoft-com:asm.v3">
  <windowsSettings>
    <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">false</dpiAware>
  </windowsSettings>
</application>

When you have a DPI >= 150% scaling can additionally controlled via RMB on application -> Properties -> Compatibility -> Scaling on high DPI

For Windows Forms the default is DPI-Scaling disables for high DPI. So everything shoud work out of the box. Maybe one of this settings is not on default? Especially the configuration in the RMB properties on the exe?

like image 173
Holger Avatar answered Sep 28 '22 11:09

Holger