private const int WM_SYSCOMMAND = 0x112;
private const int MF_REMOVE = 0x1000;
private const int SC_RESTORE = 0xF120; //还原
private const int SC_MOVE = 0xF010; //移动
private const int SC_SIZE = 0xF000; //大小
private const int SC_SIZEChange = 0xF002; //大小
private const int SC_MINIMIZE = 0xF020; //最小化
private const int SC_MAXIMIZE = 0xF030; //最大化
private const int SC_CLOSE = 0xF060; //关闭
[DllImport("USER32.DLL")]
public static extern int GetSystemMenu(int hwnd, int bRevert);
[DllImport("USER32.DLL")]
public static extern int RemoveMenu(int hMenu, int nPosition, int wFlags);
private void SetCloseMenu()
{
int hMenu = GetSystemMenu(this.Handle.ToInt32(), 0);//移除关闭按钮
RemoveMenu(hMenu, SC_CLOSE, MF_REMOVE);
}
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_SYSCOMMAND:
switch (m.WParam.ToInt32())
{
case SC_MINIMIZE:
base.WndProc(ref m);
//捕获最小化消息
break;
case SC_RESTORE:
base.WndProc(ref m);
//捕获还原消息
break;
case SC_MAXIMIZE:
this.Width = this.panel1.Width + this.textBox_Receiv.Width + 100;
this.Height = this.panel1.Height * 20;
//base.WndProc(ref m);
//捕获最大化消息
break;
case SC_SIZEChange:
this.Width = this.panel1.Width + this.textBox_Receiv.Width + 100;
this.Height = this.panel1.Height * 20;
break;
case 61443:
this.Width = this.panel1.Width + this.textBox_Receiv.Width + 100;
this.Height = this.panel1.Height * 20;
break;
case 61446:
this.Width = this.panel1.Width + this.textBox_Receiv.Width + 100;
this.Height = this.panel1.Height * 20;
break;
case 61441:
this.Width = this.panel1.Width + this.textBox_Receiv.Width + 100;
this.Height = this.panel1.Height * 20;
break;
default:
base.WndProc(ref m);
break;
}
break;
default:
base.WndProc(ref m);
break;
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)