const int WM_SYSCOMMAND = 0x112;
const int SC_CLOSE = 0xF060;
const int SC_MINIMIZE = 0xF020;
const int SC_MAXIMIZE = 0xF030;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_SYSCOMMAND)
{
if (m.WParam.ToInt32() == SC_MINIMIZE) //是否点击最小化
{
//这里写操作代码
this.Visible = false; //隐藏窗体
return;
}
if (m.WParam.ToInt32() == SC_MAXIMIZE )
{
//.....................
}
if (m.WParam.ToInt32() == SC_CLOSE )
{ //.....................}
}
base.WndProc(ref m);
}
//这个功能是 捕获最小化按钮事件 ,隐藏当前窗体.
原文地址:http://blog.csdn.net/wxm3630478/article/details/4579981