microsoft / Windows-classic-samples

This repo contains samples that demonstrate the API used in Windows classic desktop applications.
Other
5.1k stars 3.23k forks source link

Would this work in VSTO? #296

Open Shujee opened 1 year ago

Shujee commented 1 year ago

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:

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?