Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Report Viewer - scaling issue with system DPI change

I have a Winforms application (in Visual Studio 2010) that contains a Report Viewer control that previews and prints an A4 size report.

One user has his Windows font size set to 150% (i.e. a system DPI change) and when he runs the report, it is shrunk to 2/3 size in both the Report Viewer preview and the printed report.

The AutoScaleMode property of the form containing the Report Viewer is set to "Font", although it doesn't seem to affect the report if I change this.

This isn't a font (missing/scaling) issue as I have an example program to demonstrate the problem that contains nothing but a rectangle that takes up the whole page.

It seems I need some way to specify in the report itself that it should be rendered at 96dpi regardless of the system dpi setting, but can't see anywhere that I can specify this. What am I missing?

Thanks, David

like image 491
david l Avatar asked May 01 '14 15:05

david l


People also ask

How do I fix DPI scaling issues for Visual Studio 2019?

There are three options to resolve the display problem: Restart Visual Studio as a DPI-unaware process. Add a registry entry. Set your display scaling setting to 100%

How do I turn off display scaling on high DPI settings?

Right-click the application, select Properties, select the Compatibility tab, and then select the Disable display scaling on high DPI settings check box.


1 Answers

I ran into the same problem. WinForms ReportViewer is already DPI aware and will do its own scaling. You just have to tell the system that your application is DPI aware so that the system doesn't try to scale it after.

Add a manifest to your application if you haven't already, then inside the tag, add the following:

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

You can also use an API function SetProcessDPIAware, but it is recommended against: http://msdn.microsoft.com/en-us/library/ms633543.aspx

like image 82
JOMan Avatar answered Oct 12 '22 21:10

JOMan