0

I develop a VSTO add-in for Ms Word, which includes a WinForm UserControl object embedded into a Microsoft.Office.Tools.CustomTaskPane.

Development and testing are done via Visual Studio 2017, from two machines:

  1. A desktop on Windows 7 + "Low" DPI screen
  2. A laptop on Windows 10 + High DPI screen

The user control was designed from machine 1. When I open the project on machine 2, or when I compile from machine 1 and run on machine 2, I have the classic Low DPI to High DPI problems: the form layout becomes messy.

I understand the basics of DPI awareness, the various modes VS can run, and have been told that WPF handles DPI far better than WinForms.


My upmost concern is: Is there a way to design my forms from machine 1 so that they display correctly under high DPI environments? Or is it better to (re) design the forms on machine 2 ?

From this, derive other questions:

  1. Once I will have re-designed the forms from a high DPI environment, should I expect to run into the reverse problem? (i.e., dodgy High DPI to Low DPI conversions?)
  2. A CustomTaskPane only accepts WinForm UserControl objects. Would I gain anything in creating a blank UserControl in which I would embed a WPF?
  3. I target the .Net Framework 4.0. Would I gain anything (DPI compatibility-wise) in targeting a later version?

For those who bumped into this question because they face the same problem, some reading I found useful:

Ama
  • 1,373
  • 10
  • 24
  • You havent' said whether your application is DPI Aware or not. Also, possibly move to .Net 4.7+. The new DPI Awareness modes (in Windows 10) are available from there on. WPF is DPI aware by default. WinForms must be enabled explicitly by default. – Jimi Jul 28 '19 at 12:25
  • In one of the links you posted, I'm pretty sure it's specified that `PerMonitorv2` awareness can be set in both the `app.manifest` and `app.config`. The latter is the *preferred* placement by now. But it'll work with an embedded manifest anyway. – Jimi Jul 28 '19 at 12:33
  • Thanks Jimi. My knowledge on DPI considerations remains fairly basic, so I might be missing the point, but as far as I understand, since my app controls are all parented by an Office App, I do not get to chose and according to https://learn.microsoft.com/en-us/office/client-developer/ddpi/handle-high-dpi-and-dpi-scaling-in-your-office-solution, my control needs to be System DPI aware. All I want is my task pane to show at least almost identical when running on 100% or 200% scaling, keeping in mind I would prefer designing from my low DPI screen, unless it complicates things. – Ama Jul 28 '19 at 12:37
  • I suppose you refer to this link: https://learn.microsoft.com/en-us/dotnet/framework/winforms/high-dpi-support-in-windows-forms#configuring-your-windows-forms-app-for-high-dpi-support. Since my app is an Office Solution, do you know if it applies? I will run some tests targetting .Net 4.7. – Ama Jul 28 '19 at 12:42
  • 1
    I don't have any experience in VSTO implementations. I can only suggest to test it. Add the `app.manifest` file to your UserControl project, if you haven't already. Uncomment the `dpiAware` section and add `System` in the same `` section. – Jimi Jul 28 '19 at 12:45

0 Answers0