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
Related
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.'?
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?
We have an issue on our windows store app, it uses a WebView to display custom generated html from the filesystem. The app is written in WPF / Xaml and so the native UI components scale automatically depending on what the user has set their screen scaling to - however the embedded WebView does not - meaning on my laptop's 4k screen, the WebView font is incredibly tiny. At the moment we have to support windows 8.1 so we are compiling for that target - which means we are embedding a IE11 instance. I thought setting the browser zoom level may be a short term solution but it ends up with horizontal scroll bars on the main window so that's a no go.
I found a MSDN article which shows there is a problem with the underlying COM component not automatically being notified of the high DPI awareness of the app it's being embedded within. The article shows how to get around the issue by overriding what flags the component is sent. However upon going down that route, it seems the WebView that is available on the UWP platform is abstracted even further and you cant grab the instance of the Document MSHTML object needed for the above fix to work.
I also noticed this answer which seems to infer there's a scale factor conflict between windows 8.1 apps and the windows 10 OS, but I am unable to locate any more information on that particular issue.
Any advice would be most welcome as I can't imagine what we're doing is that rare.
Thanks
Turns out this is caused by a combination of factors:
We are using Bootstrap 3, which sets the root HTML font size to 10px, and as IE WebView (Even Edge) uses font size adjustments to deal with DPI scaling, having a base font size set disables this functionality.
Windows Apps which target Windows 8.1 have a maximum scaling of 200% (as that was the maximum supported at the time). However Windows 10 increased this limit to iirc 400%. My laptop screen is set to 250% as it's 4k but when I put a windows 8.1 app onto it, the maximum they go to is 200% so there is a slight size reduction there as well.
I still think this is a fairly serious issue in the Windows Store WebView control as if I open up the bootstrap site in standard edge, it is fine. Even if I do the same with IE11, the page content looks OK even if IE11 itself does not handle DPI at all.
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.
I have a strange problem. I have designed a windows form application in c# and .net framework 3.5. In the runtime, the form and its controls are fine in all the computers except my laptop, where the controls are not in the correct positions.
If I design the form from scratch on my laptop with correct positioning it will result in an invalid shape for other computers.
My efforts:
If I run the windows in Safe Mode the form size and control positions
are correct.
I have uninstalled the Video Driver and used default windows version but the problem still persists.
I used different frameworks like 2.0 and 4.0, and different Visual Studios versions and they all have the same problems.
Actually all the .net framework product from all the companies indicate the same issue.
My computer Settings:
Laptop 1557 Studio DELL
Graphic ATI Radeon HD 4500
When the text size is artificially increased to 125% text and controls that are rather closely placed will wrap around the form and push everything down/over. If this is something you intend to support, you'll simply have to redesign your form to handle the different enlargement levels you care to support and test those enlarged text modes in your app until you're satisfied with their appearance. It's not something you can strictly control, since increased text size is an accessibility feature.
I assume it is due to a screen resolution differences. I believe that the actual location of the controls is identical in both cases, in one the screen is "larger" and therefor your controls appear in a different position on the screen.
try Designing forms to work on different resolutions and aspect ratios on Windows CE
Another thing you can (and should) do is work with WPF, which is the new way to build user interfaces for windows.
I've found a workaround just now.
In the display settings of Windows 7 I have changed the Text size from 125% to 100%. Everything is smaller but in accurate positions and sizes.
Still wondering how it works!!