SetCapture (coredll)
Last changed: -216.194.17.194

.
Summary
This function sets the mouse or style capture to a specified window that belongs to the current thread. (From MSDN)

C# Signature:

[DllImport("coredll.dll")]
static extern IntPrt SetCapture(IntPtr hWnd);

VB .NET Signature:

Declare Function SetCapture Lib "coredll.dll" (TODO) As TODO

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

You can use SetCapture in conjunction with GetCapture to obtain the window handle of a Control. See the sample code below.

Sample Code:

public IntPtr GetHWnd(Control ctrl)
{
   IntPtr hOldWnd = GetCapture();
   ctrl.Capture = true;
   IntPtr hWnd = GetCapture();
   ctrl.Capture = false;
   SetCapture(hOldWnd);
   return hWnd;
}

Alternative Managed API:

None

Documentation
SetCapture on MSDN