protected override void WndProc(ref Message SystemMessage)
{
if ((int)SystemMessage.Msg == 0x005)
{
if (((int)SystemMessage.WParam) == 1)//最小化
{
MessageBox.Show("最小化");
return;
}
}
else
{
base.WndProc(ref SystemMessage);
}
}如上 拦截系统消息 当窗体最小化时 弹出 “MessageBox.Show("最小化")” 了 但为什么窗体还是最小化了???
{
if ((int)SystemMessage.Msg == 0x005)
{
if (((int)SystemMessage.WParam) == 1)//最小化
{
MessageBox.Show("最小化");
return;
}
}
else
{
base.WndProc(ref SystemMessage);
}
}如上 拦截系统消息 当窗体最小化时 弹出 “MessageBox.Show("最小化")” 了 但为什么窗体还是最小化了???
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;
}
}
base.WndProc(ref m);
}