detecting minimization

  • Thread starter Thread starter UmmagummA
  • Start date Start date
U

UmmagummA

How can I detect when the user minimize the form (when he/she press the
Mimimaze Box)?
 
UmmagummA,

There is no event that lets you know when this is going to happen.
However, you can derive from the Form class and override the WndProc method
to process the WM_SYSCOMMAND message. You want to handle the case where
wParam is equal to SC_MINIMIZE.

Hope this helps.
 
The Resize event of the form will fire on a minimize. Within the handler,
you can check the WindowState. If it is FormWindowState.Minimized then the
form is being minimized. I have not used this technique before, but you can
check to see if it works for you.

Brian Davis
http://www.knowdotnet.com
 
If you want to find the minimized state for other windows,

[DllImport( "User32.dll" )]
static extern int FindWindow( String ClassName, String WindowName );
[DllImport("User32.dll")]
private static extern bool IsIconic(int hWnd);

usage -

//get the window handle
int hwnd = FindWindow(null,"Some window title");
bool bMinimized = IsIconic(hwnd);

if bMinimized == true //its minimized
 
Back
Top