winform 判断鼠标是否在按钮控件范围内
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 public void MourseLeave() 2 { 3 bool b = this.RectangleToScreen(this.ClientRectangle).Contains(MousePosition); 4 5 //Point SQButtonPoint = this.PointToScreen(this.ClientRectangle.Location); 6 //Point MoursePoint = Control.MousePosition; 7 //bool MourseSQButton = SQButtonPoint.X + this.Width >= MoursePoint.X && MoursePoint.X >= SQButtonPoint.X && MoursePoint.Y >= SQButtonPoint.Y && SQButtonPoint.Y + this.Height >= MoursePoint.Y; 8 if (!b) 9 { 10 this.BackColor = _NormalColor; 11 } 12 }