11

After upgrading to Windows 10 my Visual Studio 2013 forms, when running, appear blurry and in a different style than what Visual Studio 2013 pictures it in design mode.

I tried installing Visual Studio 2015 and the blurry effects are still the same.

Also there are many other changes such as the elimination of 3D buttons.

This is the form in edit mode

This is the form in Run time Mode

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user2793447
  • 285
  • 2
  • 8
  • 1
    How about some pictures and a reproducer? – SamB Aug 12 '15 at 23:16
  • Pictures added also it would be nice to know why the down votes? – user2793447 Aug 13 '15 at 01:35
  • Click on the form and goto properties find AutoScalMode and change it to DPI. See if that make a difference. – EJD Aug 13 '15 at 02:56
  • 1
    Thank you for the suggestion but, the fussiness did not go away, but it did fix the Calculate Button truncation. If you look at the design view the Calculate Button word "Calculate" fits within the button just fine when it is run mode the word is truncated. – user2793447 Aug 13 '15 at 04:11

7 Answers7

6

Apparently this problem started with Windows 8, which I avoided like the plague.
This is the solution I found:

Add a manifest by going to to Project > Add New Item > Application Manifest File.

For Visual Studio 2015 and above, you can simply uncomment this code:

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

In older versions of Visual Studio, you need to add this code yourself as it won't be in the manifest automatically.

KamilDev
  • 718
  • 2
  • 7
  • 21
user2793447
  • 285
  • 2
  • 8
  • Where did you find it? I can't find it. Is this fixed the blur problem without change UI to small? – qakmak Dec 02 '15 at 03:48
  • 1
    This answer is not clear. For a better answer see this: http://stackoverflow.com/questions/13228185/winforms-high-dpi-blurry-fonts – Allan Xu May 04 '16 at 23:54
5

Call external functions to set it across your entire application. It doesn't get any easier than this:

 [STAThread]
    static void Main()
    {
        **SetProcessDPIAware();** //THIS
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }

    //ADD THESE TWO LINES !!
    [System.Runtime.InteropServices.DllImport("user32.dll")]
    private static extern bool SetProcessDPIAware();
Don P
  • 519
  • 6
  • 12
3

It is not so much Windows 10 as it is a change of DPI. Check your DPI settings in your new Windows 10 install.

Check Windows 10 DPI

If it is over 100% then that is why your application is blurry.

Look into DPI Aware Windows Forms applications.

DPI-Aware

Basically, once you go past 125%, Windows by default takes over the scaling of your UI by having your application render its output to a bitmap and drawing that bitmap to the screen. The rescaling of that bitmap makes the text look fuzzy.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
EJD
  • 751
  • 6
  • 19
  • I just checked and it is set at 100%. – user2793447 Aug 13 '15 at 04:06
  • The issue you described I was able to find the exact behaviour where your labels are fuzzy yet the form title is crystal clear. The answer I gave was the fix in that case. – EJD Aug 13 '15 at 04:11
  • Yes my Nvidia drivers are up to date, though there is a note in the nvidia control panel that they are working closely with Microsoft on direct x issues. – user2793447 Aug 13 '15 at 04:21
2

Re: Fuzzy Forms in Windows 10.

I had Windows 8.1 (OEM). All my forms were sharp and clear. I updated to Windows 10 and my forms were fuzzy. I also use VBScript and my MsgBox texts were also fuzzy.

I use a screen enlargement of 125%. Several helps which I read stated that the fuzziness disappeared when the size was set to 100%. I also found this to be true, but I wanted to use 125%.

My laptop is in German so I don't know all the English terms. I'll do my best to explain what I did.

  1. In the start page I selected Settings (???--directly above On/Off)
  2. I selected System (???)
  3. I selected Screen (???)
  4. Rather than using the 125% preset I selected Extended Settings (???)
  5. I selected Extended Size Change for Text and Other Elements (???)
  6. I clicked User Defined Scaling (???) and manually set to 125%.

It worked!!!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

This solution worked for me.

After you apply your desired font size in Windows settings (like 125% DPI, I use this with 125%) > Open Notepad, paste this into it:

REG ADD "HKCU\Control Panel\Desktop" /v DpiScalingVer /t REG_DWORD /d 0x00001018 /f
REG ADD "HKCU\Control Panel\Desktop" /v Win8DpiScaling /t REG_DWORD /d 0x00000001 /f
REG ADD "HKCU\Control Panel\Desktop" /v LogPixels /t REG_DWORD /d 0x00000078 /f

then save it as <yourname>.cmd somewhere on your HDD → open local ground policy editor (gpedit.msc from search bar) → In user config (I'm translating this from my language so there might be little translation differences) → go to Windows Settings → Scripts (login/logout) → In the window on the right double click on Login to open it (because we want this to be applied every time you login) → in Scripts tab, select Add → then in new window select Browser → navigate to where you saved your cmd file and select it → then just press OK → Apply → OK → Then sign out/reboot your pc → Log in to your account for the first time after adding this script so it will be applied → then if it will not work, Sign out/reboot again and from now on it should work every time (works for me).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
klimkin
  • 573
  • 5
  • 10
0

To fix this:

  1. Go to the Forms designer, and then select your form (by clicking at its title bar)
  2. Press F4 to open the Properties window
  3. Select the AutoScaleMode property and change it from Font (default) to Dpi.
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
vgorosh
  • 25
  • 6
0

To solve blurry fonts in running mode (crisp in design mode) in windows 10 caused by VS 2013 does not have DPI awareness ability for developed apps:

(1) in Module.vb, add the following code at the top:

   Imports System.Runtime.InteropServices
    Module Module1
        Public Declare Function SetProcessDpiAwarenessContext Lib "user32.dll" (ByVal dpiFlag As Integer) As Boolean
        Public Declare Function SetProcessDpiAwareness Lib "SHCore.dll" (ByVal awareness As PROCESS_DPI_AWARENESS) As Boolean
        Public Declare Function SetProcessDPIAware Lib "user32.dll" () As Boolean
    
        Friend Enum PROCESS_DPI_AWARENESS
            Process_DPI_Unaware = 0
            Process_System_DPI_Aware = 1
            Process_Per_Monitor_DPI_Aware = 2
        End Enum
    
        Friend Enum DPI_AWARENESS_CONTEXT
            DPI_AWARENESS_CONTEXT_UNAWARE = 16
            DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = 17
            DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = 18
            DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = 34
        End Enum
    
       
        Public Sub Main()
            Application.EnableVisualStyles()
            Dim s() As String = System.Runtime.InteropServices.RuntimeInformation.OSDescription.Split(" ")
            Dim OSver As String = s(2)
            Dim curVer As New Version()
            If Version.TryParse(OSver, curVer) Then
                'Note: the three of the following methods work with Windows 10, however SetProcessDpiAwarenessContext is the best
                If curVer >= New Version(6, 3, 0) Then ' win 8.1 added support for per monitor dpi
                    If curVer >= New Version(10, 0, 15063) Then ' win 10 creators update added support for per monitor v2
                        SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)
                    Else
                        SetProcessDpiAwareness(PROCESS_DPI_AWARENESS.Process_Per_Monitor_DPI_Aware)
                    End If
                Else
                    SetProcessDPIAware()
                End If
                Debug.Print(curVer.ToString)
            End If
            Application.SetCompatibleTextRenderingDefault(False)
            Application.Run(Form1)
        End Sub
End Module

(2) From Project Properties->Appication, uncheck "Enable application framework" 'and select Startup object as "Sub Main"

The following solution worked for VS 2017: open app.mainfest by Project Properties->Application->View Windows Settings add the Windows-10 compatibility code to app.mainfest inside block

<!-- Windows 10 compatibility -->
      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />

Also add the following code after block

<application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
    </windowsSettings>
  </application>
osbuilder
  • 196
  • 2
  • 6