我想知道鼠标是否在 .NET 中的特定控件中
private void panel1_MouseLeave(object sender, EventArgs e)
{
if (MouseIsInControl((Control)sender)
return; //the mouse didn't leave, don't fire a MouseLeave event
...
}
public Boolean MouseIsInControl(Control control)
{
//return (control.Bounds.Contains(MousePosition));
return control.Bounds.Contains(control.PointToClient(MousePosition))
}
Run Code Online (Sandbox Code Playgroud)
但我需要有人摆弄四个不同的坐标系才能使其工作。