vb.net - how to change deprecated code - Scale(ratio As Single)' is obsolete ... use Scale(SizeF) -


i have issues winform scaling, , found code here

public sub scaleform(windowsform system.windows.forms.form)         using g system.drawing.graphics = windowsform.creategraphics             dim sngscalefactor single = 1             dim sngfontfactor single = 1             if g.dpix > 96                 sngscalefactor = g.dpix / 96                 'sngfontfactor = 96 / g.dpiy             end if             if windowsform.autoscaledimensions = windowsform.currentautoscaledimensions                 'ucwindowsformhost.scalecontrol(windowsform, sngfontfactor)                 windowsform.scale(sngscalefactor)             end if         end using     end sub 

the code brilliant! want do, (scales form) though have no idea doing. following message on line windowsform.scale(sngscalefactor) 'public sub scale(ratio single)' obsolete: 'this method has been deprecated. use scale(sizef ratio) method instead.

please able me rewrite line of code using suggested change?

as said , have no idea code doing, , in order test such code in high dpi scale environment 1 can't use debugger because vs resizes new dpi settings. searched , found sparse explanations no examples , skill level nonexistent in field floundering it.

i found answer through experimentation , way shown hans passant. code designed scale form using dpi. while true can done form autoscalemode settings, issue setting cannot altered dynamicaly. have need user manually select such scaling, otherwise set none. code job well!

public sub scaleform(windowsform system.windows.forms.form)     using g system.drawing.graphics = windowsform.creategraphics         dim sngscalefactor single = 1         dim sngfontfactor single = 1         if g.dpix > 96             sngscalefactor = g.dpix / 96             'sngfontfactor = 96 / g.dpiy         end if         if windowsform.autoscaledimensions = windowsform.currentautoscaledimensions             'ucwindowsformhost.scalecontrol(windowsform, sngfontfactor)             ' windowsform.scale(sngscalefactor)             windowsform.scale(new sizef(sngscalefactor, sngscalefactor))         end if     end using end sub 

Comments