J
Jerry Spence1
A very useful feature was added in 2.0 of .NET framework which was the
scaling of a form and all the controls within it. This is really useful but
I am finding very little information of how to use it.
I have managed to implement it as follows:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim addSize As New SizeF(0.5F, 0.5F)
Me.Scale(addSize)
End Sub
And this quite rightly reduces everything down to half of what it was.
However I am wanting to put this in the Form Resize event, and I tried this
rather clumsy approach:
Private Sub Form2_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Resize
Static OldWidth As Integer
Static OldHeight As Integer
If OldWidth = 0 Then OldWidth = Me.Width
If OldHeight = 0 Then OldHeight = Me.Height
Dim ScaleX As Decimal = Me.Width / OldWidth
Dim ScaleY As Decimal = Me.Height / OldHeightDim MyScale As New
SizeF(ScaleX, ScaleY)
Me.Scale(MyScale)
OldWidth = Me.Width
OldHeight = Me.Height
End Sub
The problem is that it suffers from re-entry. As soon as the form and
everything else is scaled, the Resize event is triggered again and so on.
How are we supposed to use this scale facility?
-Jerry
scaling of a form and all the controls within it. This is really useful but
I am finding very little information of how to use it.
I have managed to implement it as follows:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim addSize As New SizeF(0.5F, 0.5F)
Me.Scale(addSize)
End Sub
And this quite rightly reduces everything down to half of what it was.
However I am wanting to put this in the Form Resize event, and I tried this
rather clumsy approach:
Private Sub Form2_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Resize
Static OldWidth As Integer
Static OldHeight As Integer
If OldWidth = 0 Then OldWidth = Me.Width
If OldHeight = 0 Then OldHeight = Me.Height
Dim ScaleX As Decimal = Me.Width / OldWidth
Dim ScaleY As Decimal = Me.Height / OldHeightDim MyScale As New
SizeF(ScaleX, ScaleY)
Me.Scale(MyScale)
OldWidth = Me.Width
OldHeight = Me.Height
End Sub
The problem is that it suffers from re-entry. As soon as the form and
everything else is scaled, the Resize event is triggered again and so on.
How are we supposed to use this scale facility?
-Jerry