Minimize override?

  • Thread starter Thread starter T250
  • Start date Start date
T

T250

I would like to override the behavior of my applications Minimize button to
Hide() but can't seem to locate where Minimize is implemented in the
framework. The closest I've found is a property where one can toggle
between the application going to the tray or to the desktop but I just want
it to be restorable from its notification icon and nowhere else.
 
Hi,

I copied the below straight from the MSDN documentation for the
From.MinimzeBox property.

Note Minimizing a form at run time generates a Resize event. The
WindowState property reflects the current state of the window. If you set
the WindowState property to FormWindowState.Minimized, the form is minimized
independently of whatever settings are in effect for the MinimizeBox and
FormBorderStyle properties.

In side the Resize event you could perform any actions needed.

Hope this helps.
 
Hi,

I copied the below straight from the MSDN documentation for the
From.MinimzeBox property.

Note Minimizing a form at run time generates a Resize event. The
WindowState property reflects the current state of the window. If you
set the WindowState property to FormWindowState.Minimized, the form is
minimized independently of whatever settings are in effect for the
MinimizeBox and FormBorderStyle properties.

In side the Resize event you could perform any actions needed.

Hope this helps.

As it turns out setting FormWindowState.Minimized led to some anomalous
behaviour when going from Maximized window to Normal (the client area
would disappear). Instead of "setting" I tested for the minimized
window state within my Resize method and all is well.

private void WinForm_Resize(object sender, System.EventArgs e)
{
FormWindowState CurrentWindowState = WindowState;
if(CurrentWindowState == FormWindowState.Minimized)
{
Hide();
}
else
{
Show();
}
}
 
Back
Top