1

I am migrating an Excel VBA Add-In to a VSTO Add-In written in C#. The user interface will include a custom ribbon tab with custom button images and five or so user forms. With the VBA version, I ignored DPI awareness without any issues.

After a lot of research, I've concluded that making the VSTO Add-In's DPI awareness fully automated across multiple display systems is a complicated task that may not yield 100% reliable results. Instead, I've written code (that the user can override) to retrieve Screen Class properties that allow my Add-In to detect the screen resolutions of all connected displays, determine the display where Excel starts, and make an educated guess regarding the optimum button image and user form sizes for that display.

I realize my approach may not be the most advanced, but it's uncomplicated and it works. Have I missed a 100% consistent way to detect the true display scaling of multiple monitors, or does my approach sound like it's a good compromise between reliability, simplicity, and user experience?

Many thanks for any opinions or experiences that can be shared!

Len-XLDev
  • 11
  • 3

1 Answers1

1

VSTO doesn't provide anything for that. Your custom ribbon UI will be scaled automatically with your Office application. But for windows forms you need to set them up properly to scale up/down correctly. So, your question goes to the Windows Forms area only. Read more about Windows Forms High DPI support in the following sources:

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Eugene, many thanks for your response. Here's a link to one blog post that discusses the scaling issues I'm concerned about: https://www.add-in-express.com/creating-addins-blog/2021/06/17/dpi-scaling-details-office-addins/ I just keep coming back to allowing the user to set their own scaling as the most reliable failsafe option. – Len-XLDev Jul 19 '21 at 17:45
  • This article doesn't describe a form set up correctly using container controls that are resized automatically when DPI is changed. But standalone controls should be adjusted as the article explains. But anyway, this is a purely Windows Forms topic. – Eugene Astafiev Jul 19 '21 at 18:13
  • @Len-XLDev, did you get any solution for VSTO scaling issue you reported ? For us it's for custom task pane. Thanks! – ManojP Aug 08 '23 at 08:33
  • @EugeneAstafiev, in case you have come across this issue and any workaround. Thanks! – ManojP Aug 08 '23 at 08:34
  • I'd suggest posting your issue separately in a new thread describing the exact problem you faced with. – Eugene Astafiev Aug 08 '23 at 16:45