- 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 || m.WParam.ToInt32() == SC_MAXIMIZE)
- {
- this.Hide();
- return;
- }
- if (m.WParam.ToInt32() == SC_CLOSE)
- {
- DialogResult dr = MessageBox.Show("关闭本程序?", "是否关闭", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
- if (dr != DialogResult.OK)
- {
- this.Hide();
- return;
- }
- }
- }
- base.WndProc(ref m);
- }
重写消息实例(实现托盘)
最新推荐文章于 2023-12-06 20:12:11 发布