經常可以看到這樣的程序,點了關閉按扭后程序并沒有關閉,而是最小化到了系統拖盤處,就像網易泡泡,msn之類的程序。實現這個其實很簡單,捕捉窗體關閉時的消息就可以了。代碼如下:
protected override void wndproc(ref message m)
{
const int wm_syscommand = 0x0112;
const int sc_close = 0xf060;
if (m.msg == wm_syscommand && (int) m.wparam == sc_close)
{
messagebox.show("用戶點了關閉按紐了");
return;
}
base.wndproc(ref m);
}
這段話放到窗體的代碼里就可以了
新聞熱點
疑難解答