System.Windows.Forms.Control.GetChildAtPoint C# (CSharp) Method

GetChildAtPoint() public method

public GetChildAtPoint ( Point pt, GetChildAtPointSkip skipValue ) : Control
pt Point
skipValue GetChildAtPointSkip
return Control
		public Control GetChildAtPoint (Point pt, GetChildAtPointSkip skipValue)
		{
			
			// Microsoft's version of this function doesn't seem to work, so I can't check
			// if we only consider children or also grandchildren, etc.
			// I'm gonna say 'children only'
			foreach (Control child in Controls)
			{
				if ((skipValue & GetChildAtPointSkip.Disabled) == GetChildAtPointSkip.Disabled && !child.Enabled)
					continue;
				else if ((skipValue & GetChildAtPointSkip.Invisible) == GetChildAtPointSkip.Invisible && !child.Visible)
					continue;
				else if ((skipValue & GetChildAtPointSkip.Transparent) == GetChildAtPointSkip.Transparent && child.BackColor.A == 0x0)
					continue;
				else if (child.Bounds.Contains (pt))
					return child;
			}
			
			return null;
		}

Same methods

Control::GetChildAtPoint ( Point pt ) : Control

Usage Example

 private bool WasNotClickedOnTarget(Control parent, Control target)
 {
     Control clickedOn = parent.GetChildAtPoint(Cursor.Position);
     if (IsNull(clickedOn)) return true;
     if (AreEqual(clickedOn, target)) return false;
     return true;
 }
All Usage Examples Of System.Windows.Forms.Control::GetChildAtPoint
Control