我在用C#写一个窗口程序,在form里有若干label,在鼠标划过这些label的时候这些处于鼠标下的label会接受到MouseMove事件,而且在form里会受到MouseLeave事件.但在我的程序中,需要的是只要鼠标没有移出窗口(即窗口矩形的边界,不论当时鼠标位置下是不是有窗口上的其他控件),窗口就需要收到MouseMove事件,而且MouseLeave事件只在鼠标离开窗口的时候才收到,是不是有办法实现?
调试欢乐多
private void Form1_MouseLeave(object sender, EventArgs e)
{
Rectangle bounds = this.RectangleToScreen(this.ClientRectangle);
if (!bounds.Contains(Cursor.Position))
{
//...
}
}