Minimize Event
—
How to determine if a Form was minimized
Problem
You want to determine if a Form was minimized or maximized.
Solution
Handle the Form.Resize event (inherited from Control.Resize),
check the Form.WindowState property for a value of FormWindowState.Minimized.
Discussion
Form does not have a Minimized, Maximized, nor Restore event.
Using the Resize event & WindowState properties you are able to determine if the
form was minimized, maximized or restored.
Example
Determine if a form was minimized, maximized or restored.
This example does attempt to differentiate between
restoring a minimized or maximized form and resizing a “normal” form.
Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
MyBase.OnResize(e)
Select Case Me.WindowState
Case FormWindowState.Normal
MessageBox.Show("Form was restored or resized", Application.ProductName)
Case FormWindowState.Minimized
MessageBox.Show("Form was minimized", Application.ProductName)
Case FormWindowState.Maximized
MessageBox.Show("Form was maximized", Application.ProductName)
End Select
End Sub