Is there an event that is fired when you maximize a Form or un-maximize it?
Before you say Resize
or SizeChanged
: Those get only fired if t
You can do this by overriding WndProc:
protected override void WndProc( ref Message m )
{
if( m.Msg == 0x0112 ) // WM_SYSCOMMAND
{
// Check your window state here
if (m.WParam == new IntPtr( 0xF030 ) ) // Maximize event - SC_MAXIMIZE from Winuser.h
{
// THe window is being maximized
}
}
base.WndProc(ref m);
}
This should handle the event on any window. SC_RESTORE
is 0xF120
, and SC_MINIMIZE
is 0XF020
, if you need those constants, too.