WindowFromPoint (user32)
Last changed: -98.115.156.13

.
Summary

C# Signature:

[DllImport("user32.dll")]
static extern IntPtr WindowFromPoint(System.Drawing.Point p);

VB.NET Signature:

<DllImport("user32.dll")> _
Private Shared Function WindowFromPoint(ByVal p As Point) As IntPtr
End Function

Oxygene.NET Signature:

[DllImport("user32.dll")]
class method WindowFromPoint(aPoint: System.Drawing.Point): IntPtr; external;

Notes:

The WindowFromPoint function retrieves a handle to the window that contains the specified point.

Make sure not to use System.Windows.Point.

Tips & Tricks:

Please add some!

Sample Code:

[DllImport("user32.dll")]
static extern bool GetCursorPos(out Point lpPoint);

[DllImport("user32.dll")]
static extern bool SetWindowText(IntPtr hWnd, string lpString);

Point p;
if (GetCursorPos(out p))
{
   IntPtr hWnd = WindowFromPoint(p);
   if (hWnd != IntPtr.Zero) SetWindowText(hWnd, "Window Found");
}

Alternative Managed API:

Do you know one? Please contribute it!

Tips & Tricks:

Please add some!

Alternative Managed API:

Do you know one? Please contribute it!

Documentation