1

I have a Win Forms application that I work on in either on my laptop or desktop. (Nothing special about the software, what i working on seems irrelevent)

Both displays on the desktop and laptop have different text scaling options.

On one computer the project layout (position of text boxes, labels etc) is fine, BUT! If you open the project on the other, everything moves and the layout ( / my GUI) ends up completely ruined. If you build / save this project, then all is lost and it all has to be reset/relocated to suit the computer your are building it on. Once the project is actually built, the application runs / looks fine. (on any screen/ res/ dpi scale) (EDIT: The built version is fine if it was built with the layout correct)

It seems that VS's designer cant handle the DPI scale change when working on the forms.

Does anyone know of a solution to this? I have changed the DPI scaling mode on several controls/forms and nothing seems to work. Its this just a Visual Studio Bug???

Thanks interwebs.

EDIT: OK Here is a twist: If you open the project with your screen text scaling set the same as the computer you last saved the project on, THEN (with VS open) change the text scaling, the controls move correctly and everything looks fine. (Stuff is where it should be) ......

Josh
  • 89
  • 12

1 Answers1

0

You may have solved this problem by now, but ... Have you tried creating an external manifest file for Visual Studio?

Process is described here: http://www.danantonielli.com/adobe-app-scaling-on-high-dpi-displays-fix/ I copied Antonielli's photoshop manifest file exactly and it seems to work fine, which does not mean I understand it. I will show it below in case someone with knowledge can correct any errors.

Just tried this now, but it seems to be working for me. I am moving windows form app dev from a 1920x1080 laptop to a 2560x1440 laptop and my app scales fine when it runs, but VS2015 screens are unreadable. So, what you see in design is a mess and NOT what you get when you run the app.

My app simply sets AUTOSCALEMODE to INHERIT on all forms and then sets AUTOSCALEMODE to FONT on main form. Various posts here discuss better methods I am sure (e.g, Creating a DPI-Aware Application and How to control the font DPI in .NET WinForms app).

Here is Antonielli's photoshop manifest file (must change registry first per his blog link above) which is saved on my computer as "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe.manifest":

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">

 <dependency>
   <dependentAssembly>
     <assemblyIdentity
       type="win32"
       name="Microsoft.Windows.Common-Controls"
       version="6.0.0.0" processorArchitecture="*"
       publicKeyToken="6595b64144ccf1df"
       language="*">
     </assemblyIdentity>
   </dependentAssembly>
 </dependency>

 <dependency>
   <dependentAssembly>
     <assemblyIdentity
       type="win32"
       name="Microsoft.VC90.CRT"
       version="9.0.21022.8"
       processorArchitecture="amd64"
       publicKeyToken="1fc8b3b9a1e18e3b">
     </assemblyIdentity>
   </dependentAssembly>
 </dependency>

 <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
   <security>
     <requestedPrivileges>
       <requestedExecutionLevel
         level="asInvoker"
         uiAccess="false"/>
     </requestedPrivileges>
   </security>
 </trustInfo>

 <asmv3:application>
   <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
     <ms_windowsSettings:dpiAware xmlns:ms_windowsSettings="http://schemas.microsoft.com/SMI/2005/WindowsSettings">false</ms_windowsSettings:dpiAware>
   </asmv3:windowsSettings>
 </asmv3:application>

 </assembly>
Community
  • 1
  • 1
Matt D
  • 73
  • 11
  • Meant to add that AFTER I created this manifest file and restarted VS2015, then I got WYSIWYG in designer (forms look fine in both designer and when running the app). – Matt D Nov 22 '16 at 02:13
  • This does not work now. I have not been sufficiently methodical to know what happened when/why, but I am getting the dreaded 'Unable to start debugging...' If I try the solution found in 37427710 (http://stackoverflow.com/questions/37427710/visual-studio-2013-high-dpi-workaround-causes-debugger-to-fail), it fails with another message: 'Error while trying to run project: ...' I will report back if/when I solve. – Matt D Jan 15 '17 at 15:02
  • Ok, instead of simply downloading the file in 37427710, I followed the process described there, and that worked fine. So, I took my post above, and added the relevant lines from DebuggerProxy.dll.manifest, as Mark W describes. Fwiw, my file is at: [link]https://www.dropbox.com/s/d42ynopa560ip3b/devenv.exe.manifest?dl=0 – Matt D Jan 15 '17 at 15:13