Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
540 views
Welcome To Ask or Share your Answers For Others

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...