Default DPI effects on Visual Studio and Windows Forms - winforms

I am having a strange effect when editing a legacy Windows Forms project in Visual Studio 2015 on my new computer with a high DPI (150%) setting. When I edit the project on the laptop screen (DPI 150) everything appears normal and the forms' default font is the standard size of 8pt (note Visual Studio's menus and text all appear correctly), but when I dock the laptop and use on my monitors with a DPI of 100 all the forms get increased to a font size of 15.25. It's almost as if somewhere, when I installed Visual Studio (and SQL Server Management Studio for that matter), they registered the DPI 150% setting as the default and when I drop back down to 100% everything is getting inverted (150/100). Anyone have any experience with this? I can't follow other articles to get my Windows Forms project DPI-Aware if I can't get back to a 96 DPI baseline.

I have solved my own issue. Documenting here for anyone else who might have this strange experience. When docked, I had three displays connected, two 1920x1200 monitors through DVI and one 1024x768 projector through VGA. Apparently this extra projector connection was creating some sort of strange DPI issues in Visual Studio's form designer (and SQL Server Management Studio's query results). Disconnecting the VGA connection fixed the problem.

Related

AutoScaleMode being ignored

I'm writing a WinForms C# application on a 4K laptop in Visual Studio Community 2017.
By default I have my Windows 10 Pro scaled to 150%. I have AutoScaleMode = none on every form and every user control.
I run my application and yet it still is scaled to 150%. I'm running VS as a DPI unaware process, and at design time my control are the right (small) size. I don't think it matters but I thought I'd mention it anyway.
Running Windows 10 Pro, fully updated.

How do I fix DPI scaling issues for Visual Studio 2017 Windows Forms

I've been encountering this issue ever since I bought this laptop with 4k display in 2015. With a lot of effort I managed to work around the issue but I'm growing tired of it.
VS2017 is supposedly DPI aware hence I do not expect any issues when creating a simple MDI Parent Form and running the app. But to my frustration the icons in the toolStrip (just the standard one in the MDI parent form) are scaled horribly.
When I create a form with a button on it which looks just fine in Visual Studio 2017 designer and I run the app and load the form, the button text isn't completely shown.
My display settings are as follows:
Resolution: 3840x2160
Scaled 250% (in display settings) because at 100% everything is unreadable
I've tried to find solutions, but the only workable thing I could find was setting my visual studio designer to dpi-unaware via registry (link here)
Help anyone?
Update When I add a new MDI form with the setting of DPI-awareness OFF, everything looks OK except Visual Studio itself (blurry).
I have similar problem when working with Windows Forms (Windows Forms Designer) on Visual Studio 2017, but I think it would be the same on Visual Studio 2019.
From Microsoft documentation here, there is a tip to disable the scaling/DPI aware feature.
If you prefer to manage settings from the command line, devenv.exe
takes /noscale as a command-line parameter to run in 100% scaling
mode.
So, basically, I just created a shortcut on the Desktop to Visual Studio (devenv.exe) and added the parameter /noscale on the shortcut Target field like so:
"...\path\to\IDE\devenv.exe" /noscale
So, everytime Visual Studio is started through the shortcut, it will always start with 100% scaling mode. If you use high resolution screen (high-dpi) screen, you will notice that the Visual Studio text will appear a little bit blurry because of this.
You should change the settings so there won't be a difference when the program runs on different machines.
Go to the project's properties page, then to Manifest Tool and then Input and Output. Change the DPI awareness to 'none'

Visual Studio and DPI issue

I am developing a Windows Forms application using VS2008 on Windows Vista. I tried to run my application on Windows XP the other day, and everything on GUI was messed up. I realized that I developed the application using 120 Dpi setting on Windows Vista and my XP was set to 96 dpi.
My application has several UserControls and all of them shrinks even in the Visual Studio itself if I change my DPI to 96. I am sure a lot of people are using Visual Studio in high DPIs these days. So how can make sure that my GUI does not get messed up both in Visual Studio and runtime?
EDIT: I have read couple articles on this issue and I learned that I should be setting AutoScaleMode to None. However, this still does not prevent my labels to adapt new DPI settings enforced by the operating system. I need a way to prevent my labels to grow/shrink because other GUI elements have fix sizes.
It has been a while since I worked on this issue, but try setting AutoSize = False. In addition, UseCompatibleTextRendering = True might help.
This is a rather old question, but I want to share my solution/opinion. I ran into a similar problem recently. Actually, I want Visual Studio to keep my WinForms as they are, but them to scale at runtime. I found no consistent summary on how to correctly do that. After some reading and experimenting I came to this solution:
Keep the Form’s AutoScaleMode = Font.
Set in your Forms Designer: Font = MS Sans; 11px
In the Forms Ctor, after InitializeComponent, set: Font = SystemFonts.DefaultFont
Enable DPI-Awareness, either through a manifest or by API function SetProcessDPIAwareness
Since AutoScaleMode remains active, all DPI-changing magic works, even per-monitor DPI awareness. What remains, is designing Forms in a way scaling works nicely.
I wrote the details on my Blog: http://www.sgrottel.de/?p=1581&lang=en

Winforms control spacing in Windows 7

We have an in-house .net 2.0 winforms app currently developed on Visual Studio 2005 in Windows XP. Everyone in the office until now is running Windows XP, and there are no issues.
We recently ordered a new computer with Windows 7 for one of our managers we were hoping to use, and the app installs fine. The issue is the spacing around every label, textbox, and button - making some forms not fit.
Is there some setting that we can use to make Windows 7 display each control where it is placed in our XP development environment and like the rest of our XP clients show?
Ugh, what kind of idiot management team gives a new machine to a manager instead of a programmer?
Control Panel + Display, Advanced tab, change the DPI setting to repro the problem on your XP machine. Read the docs for the Form.AutoScaleMode to find out what's going on.

Why does Visual Studio 2010 have rendering problems in VMware?

We were testing our WPF application on Windows XP in the VMware Player (with VMware Tools) and noticed that dropdowns were buggy in that all the choices would appear when you clicked on the ComboBox but as you moused over them they would disappear.
We then noticed that Visual Studio Express 2010 has the exact same problem with its menus.
Here a menu item is hanging by itself in the middle of the screen:
Here a menu item is stretched:
We have WMware Tools installed:
We would definitely like to get our application to work without these bugs in VMware. Has anyone experienced these problems and know if it is a problem with VMware, XP, WPF, or WPF 4.0?
I had the same problem and based on a VMWare support article http://kb.vmware.com/kb/1011709 I changed my graphics adapter from VMWare SVGA II to the default (native) Windows 7 driver.
This solved the problem for me.
I read this post to install two patches for Visual Studio 2010 and WPF. This solves the problem.
I've found problem with selection and scrolling during code editing.
Sometimes the text disappears and other times the selected text becomes unreadable.
If you turn of VMWare SVGA you can't resize the screen at any size.
I solved it enabling Aero themes (google for "install aero on windows 8").
Don't ask me how but it solves my problem.

Resources