C#窗体的最大化/最小化/还原/最小化到托盘/NotifyIcon的代码实现
|
源代码网整理以下1.最小化 软件开发网 www.mscto.com this.myTimer.Enabled = false; //this.Hide(); //设置气球状工具提示显示的时间为10秒 this.notifyIconCMPC.ShowBalloonTip(30); } #endregion #region 重写WndProc屏蔽掉关闭按钮 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) { this.Visible = false; return; } base.WndProc(ref m); } #endregion private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) { if (this.WindowState == FormWindowState.Minimized || this.Visible == false) { this.normalForm(); } else { minForm(); } } 源代码网推荐 源代码网供稿. |
