Completed
Last Updated: 28 Aug 2017 11:48 by ADMIN
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 23 May 2017 06:31
Category: UI Framework
Type: Bug Report
4
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.

Workaround:
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)

            Return
        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))

        formOnOnLoad(e)
    End Sub

End Class
1 comment
ADMIN
Ralitsa
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;