1
votes

We have an application (WPF) that hosts an out of process application (MFC) as a child window in an hwndhost. When setting a custom DPI setting (i.e. 125% in Display property of Windows), the child window does not scale appropriately to the change in DPI. This is a legacy application that is not DPI Aware. When launching the out of process application stand alone, it scales as desired (using auto display scaling from Windows). Is it possible that because we are making this out of process application a child of our WPF window, it is inheriting the DPI Awareness from its parent? Any way to fix this?

I found a similar issue here: Win32 app not affected by dpi setting when hosted by WPF app but no answer was proposed. I would comment on the original question to see if it was figured out but I do not have enough rep and want to re-open the question to see if there is a solution.

1
Yes, PresentationCore calls SetProcessDPIAware() in its module constructor, Process being the operative word. Unless you add a [assembly:DisableDpiAwareness] attribute to your EXE project's AssemblyInfo.cs source file. 125% is not enough to enable automatic DPI scaling btw, it doesn't start until 150%.Hans Passant
were you able to solve this?cat_in_hat

1 Answers

0
votes

The DPI awareness of a top-level window is determined by the process that owns that top level window. In your case that's the WPF window. The system uses the same DPI virtualization for all children of a top level window.

If you want your hosted child window to be virtualized then you would need the top-level window also to be virtualized. Which I expect you do not want to happen.