整个窗口的C#MouseEnter-Event

时间:2012-04-11 08:50:45

标签: c# mouseenter

是否可以为窗口的边框创建MouseEnter-Event?我的意思是最小化和最大化按钮。因为如果我为Form1设置了Event,它只在我在Form中时才有效,但在边框和Buttons上却没有。

1 个答案:

答案 0 :(得分:4)

您可以在窗体中覆盖WndProc,并且可以检测mousemove

protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            // mouse in window or in Border and max, close & min buttons     
            if (m.Msg == 0xa0 || m.Msg == 0x200)
            {
                //Do some thing
            }
        }