Detecting whether form was minimized before OnResize()

  • Thread starter Thread starter Valerie Hough
  • Start date Start date
V

Valerie Hough

In the OnResize() event is it possible to detect whether the form is really
being resized as opposed to just restoring itself to its previous size?

Presumably I could keep track of the size of the clientRectangle but it
seems as though there must be an easier way.

Thanks in advance.

Valerie Hough
 
Hi Valerie,

/// <summary>Stores the last known <see cref="FormWindowState" />
/// during a <see cref="Resize" /> event.</summary>
private FormWindowState lastResizedState;

protected override void OnResize(EventArgs e)
{
base.OnResize(e);

if (lastResizedState == this.WindowState)
// form is resizing, but not switching state
{
// do stuff during resize
}
else
// keep track of the state change
lastResizedState = this.WindowState;
}
 
Back
Top