很简单的一个C#中双击标题栏关闭WinForm程序,估计很多人在写程序的时候用的着,程序代码只有段段的几行。
没有事件,只能通过重写WndProc,过滤需要的消息来实现:
public const int WM_NCLBUTTONDBLCLK = 0xA3;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_NCLBUTTONDBLCLK)
{
this.Close();
}
base.WndProc(ref m);
}
转自:http://addday.iteye.com/blog/187490