C# WndProc的使用方法 (转)

来源:互联网 发布:泰州韵知商贸有限公司 编辑:程序博客网 时间:2024/04/29 05:54
WndProc(ref Message m)
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.WindowState = FormWindowState.Minimized;
        return;
     }
    base.WndProc(ref m);
}

protected override void WndProc(ref    Message m)
{
     const int WM_SYSCOMMAND = 0x0112;
     const int SC_CLOSE = 0xF060;
     const int SC_MINIMIZE = 0xF020;
     if (m.Msg == WM_SYSCOMMAND && ((int)m.WParam == SC_MINIMIZE || (int)m.WParam == SC_CLOSE))
     {
         //最小化到系统栏
         this.Hide();
         return;
     }
     base.WndProc(ref    m);
}
转贴地址:http://www.cnblogs.com/zeroone/archive/2010/03/31/1701084.html
原创粉丝点击