-
May 9th, 2019, 05:16 AM
#1
Thread Starter
Frenzied Member
Zooming in/out on WinForm
Hi,
It seems from what I research that it is not possible to zoom in/out of normal WinForm. So I am looking for maybe a clever method to implement some zoom in/out effect.
My problem is that I have a userform with textboxes, datagridviews, labels, etc. When I use a overhead projector then some people sitting at the back can not see properly.
How can I (temporary) make it bigger?
Thanks
-
May 9th, 2019, 06:17 AM
#2
Addicted Member
Re: Zooming in/out on WinForm
Code:
Public Class Form1
Const ZoomFactor As Single = 2
Private Sub Form1_MouseWheel(sender As Object, e As MouseEventArgs) Handles Me.MouseWheel
Dim Zoom As Single
If e.Delta > 0 Then
Zoom = ZoomFactor
Else
Zoom = 1 / ZoomFactor
End If
Me.Scale(New SizeF(Zoom, Zoom))
End Sub
End Class
Utterly useless, but always willing to help
As a finishing touch god created the dutch
-
May 9th, 2019, 07:52 AM
#3
Thread Starter
Frenzied Member
Re: Zooming in/out on WinForm
Originally Posted by Goggy
Code:
Public Class Form1
Const ZoomFactor As Single = 2
Private Sub Form1_MouseWheel(sender As Object, e As MouseEventArgs) Handles Me.MouseWheel
Dim Zoom As Single
If e.Delta > 0 Then
Zoom = ZoomFactor
Else
Zoom = 1 / ZoomFactor
End If
Me.Scale(New SizeF(Zoom, Zoom))
End Sub
End Class
Hi Goggy, thank you for you reply. Not what I have in mind
-
May 9th, 2019, 04:46 PM
#4
Re: Zooming in/out on WinForm
Assuming you use the form's default scaling mode (AutoScaleMode.Font) you only need change the font size. I suppose you want to keep the form centred too, in which case you could use a method like this:
Code:
Private Sub ScaleForm(scale As Single)
Me.AutoScaleMode = Windows.Forms.AutoScaleMode.Font
Me.Font = New Font(Me.Font.FontFamily, Me.Font.Size * scale)
Me.Left += CInt(Me.Width * (1 - scale) / 2)
Me.Top += CInt(Me.Height * (1 - scale) / 2)
End Sub
Or have I failed to read your mind correctly?
BB
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|