Please bear with the length of this description. The problem is weird, and I want to give some background.
I am including an image of the issue. The image on the left is the newer and blurry version.
To preface:
I am using winforms. Windows 10. Visual studio 2019. I think I am using 2019 on both computers, but I know I am on this one.
I am an amateur programmer, but have been working on a big project. It started out as a personal tool, but now I have ideas of making it available to others.
I am not sure what code to share because the project is so long and has become quite convoluted. It has half a dozen different forms as well as half a dozen custom controls etc.
As somebody who taught himself C# for this project, my programming hygiene wasn’t that good. I have learned enough that my next project will be better, but I have put years into this and can’t reasonably start over.
I noticed the problem of blurry fonts when bringing the program to a different computer.
This problem was not present in the version from a bout 6 mo ago, but I am not sure when it was introduced. If it is showing up on the computer I was using then the issue was introduced, then it wasn’t as obvious on those monitors.
I have an eye condition so until it was really obvious on my more powerful machine, I was unsure there was a problem. This makes it difficult to pinpoint where it happened. I don’t know if it was visible on the other machine to somebody with better eyes or not.
The computer that makes the problem obvious has four monitors, a more modern graphics card, and one of the monitors is 4k. But both run win 10.
The problem:
The font is blurry.
It looks like the font for the form (Form.text) is still sharp, though it is such a small font maybe it isn’t. Perhaps somebody with better eyes can tell. Everything else, the menus etc, is blurry.
I have tried:
Changing autoscale mode from “font” to DPI, but neither look right. They look different but neither looks sharp.
Other issues:
The program seems to look better (less burry) when I am debugging it in VS. When I run the main exe is when the problem really shows.
Some other behavior of the program is also a bit different when it runs as an exe, such as the program appears in different locations on the screen (the program remembers its previous location each time it is shut down—but I am not sure why running the exe and debugging it should behave differently).
Possibly related: I have also noticed that when debugging and stopping at a break point it no longer shows me variable values when I hover over them. I have no idea if this is related or not. I had hoped that when I ran the program on a different version of visual studio this would resolve itself, but this is a fairly recent behavior that I haven’t been able to resolve that may or may not be related. I don’t see why they would be related, but none of this is making any sense to me and both problems seem to have originated about the same time.
This behavior is so bizarre, and my program is so large, I am not sure where to start.
I can’t really show sample code, because I don’t know what is relevant.
If you read through all of this, thank you. Any help deeply appreciated. I have no idea where to even start looking for this solution. The only thing I could find online was changing from “font” to “DPI” scale mode, but again that didn’t work.
This is driving me batty.
Looks like the usual DPI stuff. Windows assumes your application can’t handle different DPI values, so it’s being drawn with the standard 96 DPI and then getting upscaled to match the higher DPI of the screen.
Try this: https://docs.microsoft.com/en-us/dotnet/desktop/winforms/high-dpi-support-in-windows-forms
I have also noticed that when debugging and stopping at a break point it no longer shows me variable values when I hover over them
Make sure you’re not using the release build for debugging, and you haven’t enabled optimizations for the debug build in the project settings.
Apparently, a known issue with WinForms. This thread on SO seems to have some decent info. Also, this article.
Does the blurry PC have a large monitor with display scaling set to something other than 100%
This is what’s wrong
You need to handle scaling, or else it’s going to render without scaling and stretch that to cope
You can check to make sure that this is really what’s wrong by temporarily setting your desktop scaling to 100%. If the problem disappears, this was it.
Windows Forms is legacy tech. Probably don’t use it unless you’re stuck
Well, it is really too late to totally rewrite the program.
Is there a way to fix it so that the scaling will work?
Or is there a converter that can take my win-forms project and turn it into WPF? I really can’t imagine re-writing the entire thing. I’m not lazy, but I have been working off and on for this for years.
C# devs
null reference exceptions