My company has a large legacy Delphi application that we're attempting to migrate gradually to the .Net framework. We've settled on implementing new GUI elements using WPF and exposing them via COM. I believe this is fairly standard, since I've seen quite a lot of material online about people doing exactly this.
So far so good, our proof of concepts / demo samples have been working fairly well. We expose various "create element X" methods via a COM interop library, which return the Hwnd of the newly created HwndSource wrapper. We then call SetParent to place the new control where it needs to be in the Delphi application.
The only problem now seems to be that the legacy Delphi and new WPF GUI elements are having trouble coexisting when the DPI settings are set to anything other than 96dpi.
We've never handled high DPI especially well in the Delphi application, so just recommend that clients use the Windows (non-XP) scaling to enlarge the application on High DPI monitors.
However, this seems to be causing a conflict with the new WPF elements, since they seem to be already rendering at the increased DPI setting, and then get blown up again (maybe? I'm not 100% sure where the issue lies here) by Windows scaling the entire application.
What I'd like to try now is to disabling the automatic scaling of these WPF elements, bringing them into the Delphi application as if the monitor was set to 96dpi. We'd then let the windows scaling bump them back up to the desired DPI.