microsoft/Windows-classic-samples

Would this work in VSTO?

Shujee opened this issue · 0 comments

Shujee commented

I'm trying to use this project in a VSTO project that uses WPF for the UI. Since VSTO add-ins are in-process DLLs and their main process is the Office application itself, this approach doesn't seem to work. I have completed all the required steps:

  • Added [assembly: DisableDpiAwareness] to AssemblyInfo.cs.
  • My windows inherit from NativeHelpers.PerMonitorDPIWindow.

For some reason, SetProcessDpiAwareness call in PerMonitorDPIHelper.cs fails. I have tried using GetWindowDpiAwarenessContext and GetAwarenessFromDpiAwarenessContext to find that the Excel workbook window uses PER MONITOR setting, whereas my WPF windows are using SYSTEM DPI for some reason.

What else do I need to do here?