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
Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
1 answer
Sort by: Most helpful
-
Castorix31 91,511 Reputation points2021-09-26T08:22:25.317+00:00