I have some issues with Winform scaling, and found this code here
Public Sub ScaleForm(WindowsForm As System.Windows.Forms.Form)
Using g As System.Drawing.Graphics = WindowsForm.CreateGraphics
Dim sngScaleFactor As Single = 1
Dim sngFontFactor As Single = 1
If g.DpiX > 96 Then
sngScaleFactor = g.DpiX / 96
'sngFontFactor = 96 / g.DpiY
End If
If WindowsForm.AutoScaleDimensions = WindowsForm.CurrentAutoScaleDimensions Then
'ucWindowsFormHost.ScaleControl(WindowsForm, sngFontFactor)
WindowsForm.Scale(sngScaleFactor)
End If
End Using
End Sub
The code is brilliant! It does what I want it to do, (scales the form) even though I have NO idea WHAT it is doing.
However I get the following message on this line WindowsForm.Scale(sngScaleFactor)
'Public Sub Scale(ratio As Single)' is obsolete: 'This method has been deprecated. Use the
Scale(SizeF ratio) method instead.
Please would someone be able to help me to rewrite the line of code using the suggested change?
As I said , I have no idea what the code is doing, and in order to test such code in high DPI scale environment one can't use the debugger because VS resizes everything to the new DPI settings. I also searched and found some very sparse explanations with no examples and as my skill level is nonexistent in this field I am floundering with it.