How to Convert this DPI Matrix transform code into C++?

MERUN KUMAR MAITY 636 Reputation points
2021-09-25T18:42:56.343+00:00

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.
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 91,511 Reputation points
    2021-09-26T08:22:25.317+00:00

    This code is for WPF
    You can find the same code (less compacted, in different functions) in MS C++ sample : PerMonitorDPIWindow.cpp


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.