首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

真个实现窗口最小化时自动最小化到托盘

2012-11-26 
真正实现窗口最小化时自动最小化到托盘#region 最小化到托盘const int WM_SYSCOMMAND 0x0112const int

真正实现窗口最小化时自动最小化到托盘

   #region 最小化到托盘
        const int WM_SYSCOMMAND = 0x0112;
        const int SC_MINIMIZE = 0xF020;//最小化
        const int SC_MAXIMIZE = 0xF030;//最大化
        const int SC_RESTORE = 0xF120;//还原时
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            if (m.Msg == WM_SYSCOMMAND)
            {
                int sc = m.WParam.ToInt32();
                if (sc == SC_MINIMIZE)
                {
                    this.Hide();
                }
            }
        }
        #endregion

热点排行