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.
Related
I have a C# desktop application which is developed in dot net framework 4.6.2. This application is working finr in Win 10. But when same application is run in Win 11, all form controls are disturbed. Like few buttons are totally hidden. Is there any global fix? I don't want to reposition and resize the forms and controlls again for the whole application.
The issue you have is because the Windows 11 computer has a different screen DPI setting. Winforms is notoriously bad at scaling with any setting other than 100%. If you cannot run 100% all the time, then you will have to do some coding magic to detect DPI setting and adjust margins and padding... Or you could redo your UI in WPF, which scales properly at any setting.
Some possible avenues to explore if you rebuild to .NET 4.7+:
https://learn.microsoft.com/en-us/dotnet/desktop/winforms/high-dpi-support-in-windows-forms?view=netframeworkdesktop-4.8
I'm using Avalonia UI to create an application that is available for both Windows as well as macOS, and have come across the issue that, when using a macOS device that has a Retina display, the entire application is scaled up quite massively, estimated about two times. This means that my application, which, in its smallest form is about the size of the Windows Explorer default, actually falls outside of the screen on these Retina displays, which, of course, is not ideal.
Is there a solution?
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.'?
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
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!!