Minimize button event
-
Hi guys, Does anyone know how I can capture the event when a user clicks the Minimize button on the control box in C#? I want to issue a warning messagebox when they click on it. And why does the message box show nothing on it, even though I have set all the parameters in the messagebox function properly? There are nothing on it except an empty button with no caption. Please help...:confused:
-
Hi guys, Does anyone know how I can capture the event when a user clicks the Minimize button on the control box in C#? I want to issue a warning messagebox when they click on it. And why does the message box show nothing on it, even though I have set all the parameters in the messagebox function properly? There are nothing on it except an empty button with no caption. Please help...:confused:
In order to catch the minimize event of an window you moust intercet the WM_SYSCOMMAND message and check that the WParam is SC_MINIMIZE. How can you do this? Simple, override the
WndProc
of your form :protected override void WndProc(ref Message m)
{
if(m.Msg == 0x112) // if WM_SYSCOMMAND
{
if(m.WParam.ToInt32() == 0xf020) //if SC_MINIMIZE
{
// process here what you want
return; // if you want to not to minimize, or call base.WndProc (ref m) if you do not
}
}base.WndProc (ref m);
}
I hope you understand...because is a rough world out there...
-
Hi guys, Does anyone know how I can capture the event when a user clicks the Minimize button on the control box in C#? I want to issue a warning messagebox when they click on it. And why does the message box show nothing on it, even though I have set all the parameters in the messagebox function properly? There are nothing on it except an empty button with no caption. Please help...:confused:
Hook the Resized event of the form and then check that the WindowState is equal to FormWindowState.Minimized. If it is, issue your messagebox and do anything else that you want to.