VS2013 - Issue with high DPI screen and WinForms - c#

I built an application on a computer with normal DPI size. It is a WinForms application with many forms and custom controls. When I open the project on my Lenovo Yoga 900 with high DPI it looks good in Visual Studio 2013 but when I run the application some parts are off screen.
Even worse is when I open the application after a change on my "normal DPI computer". Most of the controls are scaled up, margins and paddings are scaled too.
With other words my forms are messed up. I've read about the AutoScaleMode which is set to Font. Even I change that property there are not realy noticable changes.
Any suggestions how I can handle that problem? Or does someone have similar experiences/issues?

Related

How to set High DPI scaling override to System (Enhanced) for WinForms app

I have an old-school ordinary WinForms app in VS2019, for which the tabs on a tab control are vertically squished on a high-DPI monitor. In fact, if the app is opened on a high-DPI monitor and dragged to a regular monitor, the tabs remain squished. I want the app to automatically scale the controls properly. As a user, I can make that happen post-installation by adjusting Compatibility Settings on the executable: [Properties->Compatibility->Change high DPI settings->High DPI scaling Override->Override high DPI scaling behavior. Scaling performed by System (Enhanced)]. I don't want the user to have to do that -- I'd rather fix it in the source code.
I've read dozens and dozens of articles on this subject and it seems they are all outdated, as the 'recommended method' has changed several times over the past few years (and none of them seem to work). The bottom line is that it seems likeI need to do the opposite of what most of them advise -- specifying that the app is DPI-aware (i.e. turning 'DPI-awareness' 'on'). It is NOT DPI-aware, but the 'System (Enhanced)' scaling (seemingly intended precisely for non-DPI-aware apps) works great. But maybe I misunderstand what 'DPI-awareness' means.
What is currently the best practice for specifying programmatically (or via the manifest) that 'this app does not have any provisions for scaling itself or being aware of how many pixels per inch your monitor has, but allowing "System (Enhanced)" scaling from Windows 10 works great. Please do that.'?

Windows Forms - Make controls the same size across displays

I have been looking into High DPI support for Windows Forms, as per the following link.
https://learn.microsoft.com/en-us/dotnet/desktop/winforms/high-dpi-support-in-windows-forms
However, I'm not sure exactly what the High DPI support actually accomplishes, does the High DPI support simply mean that controls and fonts will be rendered smoothly on High DPI displays?
I have tried enabling High DPI via an Application Manifest File in my Windows Forms project, but this didn't seem to have any visible effect on the application. Everything still appears to be the same size within the application.
--
I've also been looking at the following link regarding automatic form scaling.
https://learn.microsoft.com/en-us/dotnet/desktop/winforms/forms/autoscale
However, again I'm not sure what this is saying, will the auto-scaling actually make controls and fonts look bigger on a high DPI display?
--
Now for my actual problem.
I am designing a form which is 405x720 pixels in size on a 24 inch 1920x1080 display # 96 DPI. I want the controls and fonts on the form to have the same physical dimensions when displayed fullscreen on a 6 inch 720x1280 screen which is around 244 DPI.
There is a potential solution for this at the following link.
Scale windows forms window
Is an approach similar to the one in the above StackOverflow link above still the only way to achieve what I am looking for regardless of the High DPI improvements in the latest versions of .NET, or am I potentially missing something with the High DPI and automatic scaling?

WPF application "bitmap-scaled" on Remote Desktop with Hi DPI

My WPF application works well on Hi-DPI display (e.g. My Yoga Pro 2 laptop, with 192 DPI display (13 inch, 3200x1800).
All vector-defined GUI elements are crisp and sharp - without any explicit programming for that. Seems then WPF can pick the proper rendering DPI matching DPI of the display and automatically all is fine. As far as the program is running locally.
However, when the same application is run on remote desktop, (connection to local Virtual machine with "enhanced" desktop mode) - the application is rendered # 96 DPI, and scaled-up twice to have proper size. The problem is that this scaling is bitmap-scaling which naturally produces blurry/pixelated appearance.
I believe that this should be plain-easy to declare something to make the app rendered "natively" with the High DPI on the RDP, without the need to scale it afterwards (by the system anyway) to make it expected size.
I tried to set in app.manifest
true
but, it did not solve the problem...
Any ideas ?
Btw - other applications (e.g. Windows Explorer can render on RDP at proper DPI, without later being scaled up to match natural size (note: on high DPI everything looks small if not rendered natively with high dpi).
I've isolated the problem to a blank WPF application with a mere TextBlock to display. This app, when run on RDP (Windows 10 Creators version or later) can easily be used to reproduce the problem (The text is proper size, but is bitmap-scaled (as part of the whole application scaled up)).
Thanks,
Michael

WPF application window not scaled on second monitor

My WPF application window is not scaled on the second monitor, running Windows 10.1607. The built-in monitor runs at 200% (high DPI) and the external monitor at 100% scaling. Most other program windows change their size and internal scaling when they are moved between monitors, but mine does not. It appears huge on the external monitor, and has double the icon and text size compared to correct scaling.
The application targets .NET Framework 4.0 and the app.manifest file contains the relevant entries for Windows 10 support and dpiAwareness. Even if I remove these entries, it doesn't change. I don't know whether this has worked before, I couldn't find an old version that does.
What do I need to do to let Windows scale my window on a different-DPI monitor just as any other window? I don't currently expect it to be sharp (.NET 4.6.2 has news to that), blurry rescaling is okay. But it just needs to do anything and not render the window at 200% on a 100% monitor.
Seems to be a Windows/Surface bug. Every time I resume the Surface Pro 4 (all updates installed) from standby, a number of applications are not rescaled when moved to another monitor. After a logoff and logon, it works normally again.

Scaling to different resolutions in C# with Visual Studio

I am creating a windows form application in Visual Studio Community 2015. I've built the interface on a 1080p monitor and anchored controls so that when the form is resized, things stay where I want and stretch how I want.
The problem is, I need to try and get this to work on a monitor that is 1024 x 768 and the minimum size of my application is actually larger than that. This causes controls to overlap due to the anchoring and some controls aren't shown at all (they are cut off).
Is there anyway I can easily scale my application to different resolutions automatically?

Categories