Last Updated: 28 Aug 2017 11:48 by ADMIN
Dess | Tech Support Engineer, Principal
Created on: 23 May 2017 06:31
Category: UI Framework
Type: Bug Report
FIX. TPF - DPI scaling can't be disabled on Windows 7
To reproduce: if you set in the app.manifest file  <dpiAware>false</dpiAware>, the controls still scale when changing DPI.

Public Class RadForm1
    Protected Overrides Sub OnLoad(e As EventArgs)

        Dim allowTheming = DirectCast(GetType(RadForm).GetField("allowTheming", BindingFlags.Instance Or BindingFlags.NonPublic).GetValue(Me), Boolean?)

        Dim behavior As ThemedFormBehavior = TryCast(Me.FormBehavior, ThemedFormBehavior)
        If behavior IsNot Nothing AndAlso allowTheming.HasValue AndAlso behavior.AllowTheming <> Me.AllowTheming Then
            behavior.AllowTheming = allowTheming.Value
        End If

        If Me.IsDesignMode Then
            GetType(RadFormControlBase).GetField("initialFormLocation", BindingFlags.Instance Or BindingFlags.NonPublic).SetValue(Me, Me.Location)

        End If

        Dim mi As MethodInfo = GetType(Form).GetMethod("OnLoad", BindingFlags.Instance Or BindingFlags.NonPublic)
        Dim ptr As IntPtr = mi.MethodHandle.GetFunctionPointer()
        Dim formOnOnLoad As Action(Of EventArgs) = DirectCast(Activator.CreateInstance(GetType(Action(Of EventArgs)), Me, ptr), Action(Of EventArgs))

    End Sub

End Class
1 comment
Posted on: 28 Aug 2017 11:48
In order to disable DPI scaling on Windows 7 OS, you need to set the EnableDpiScaling property to false. Here is the code snippet demonstrating how to achieve it:
RadControl.EnableDpiScaling = false;