B
Bernie Yaeger
I'd like to allow the user to zoom a window using a trackbar, say from 80%
to 120% the size of the original window. I'm trying to do this with the
following code, but it fails pretty miserably:
(from the form)
Dim per As Decimal
per = CDec(zoomit.Value)
setzoom(Me, Me.Font, per) ' per is the current value of the trackbar as a
decimal
----------------------
Public Sub setzoom(ByRef senderform As Form, ByRef senderfont As Font, ByVal
per As Decimal)
per = per * 0.01
Dim iwidth As Int32 = SystemInformation.PrimaryMonitorSize.Width
Dim sizeold As SizeF =
System.Windows.Forms.Form.GetAutoScaleSize(senderfont)
senderfont = New Font(senderfont.FontFamily, senderfont.Size * iwidth /
1280)
' 1280 is my current environment width
Dim sizenew As SizeF =
System.Windows.Forms.Form.GetAutoScaleSize(senderfont)
sizenew.Width = sizenew.Width * per
sizenew.Height = sizenew.Height * per
senderform.Scale(sizenew.Width / sizeold.Width, sizenew.Height /
sizeold.Height)
End Sub
Thanks for any help.
Bernie Yaeger
to 120% the size of the original window. I'm trying to do this with the
following code, but it fails pretty miserably:
(from the form)
Dim per As Decimal
per = CDec(zoomit.Value)
setzoom(Me, Me.Font, per) ' per is the current value of the trackbar as a
decimal
----------------------
Public Sub setzoom(ByRef senderform As Form, ByRef senderfont As Font, ByVal
per As Decimal)
per = per * 0.01
Dim iwidth As Int32 = SystemInformation.PrimaryMonitorSize.Width
Dim sizeold As SizeF =
System.Windows.Forms.Form.GetAutoScaleSize(senderfont)
senderfont = New Font(senderfont.FontFamily, senderfont.Size * iwidth /
1280)
' 1280 is my current environment width
Dim sizenew As SizeF =
System.Windows.Forms.Form.GetAutoScaleSize(senderfont)
sizenew.Width = sizenew.Width * per
sizenew.Height = sizenew.Height * per
senderform.Scale(sizenew.Width / sizeold.Width, sizenew.Height /
sizeold.Height)
End Sub
Thanks for any help.
Bernie Yaeger