This code is for WPF
You can find the same code (less compacted, in different functions) in MS C++ sample : PerMonitorDPIWindow.cpp
How to Convert this DPI Matrix transform code into C++?
MERUN KUMAR MAITY
636
Reputation points
Here is the code -
public class DpiDecorator : Decorator
{
public DpiDecorator()
{
this.Loaded += (s, e) =>
{
System.Windows.Media.Matrix m = PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice;
ScaleTransform dpiTransform = new ScaleTransform(1 / m.M11, 1 / m.M22);
if (dpiTransform.CanFreeze)
dpiTransform.Freeze();
this.LayoutTransform = dpiTransform;
};
}
}
Windows development | Windows API - Win32
2,789 questions
Developer technologies | C++
3,977 questions
Developer technologies | C#
11,578 questions
1 answer
Sort by: Most helpful
-
Castorix31 90,686 Reputation points
2021-09-26T08:22:25.317+00:00