当前位置: 编程技术>.net/c#/asp.net
获得.net控件的windows句柄的方法
来源: 互联网 发布时间:2014-10-18
本文导语: 代码如下:class WinAPI{ [DllImport("coredll.dll")] private static extern IntPtr SetCapture(IntPtr hWnd); [DllImport("coredll.dll")] private static extern IntPtr GetCapture(); public static IntPtr GetHWnd(Control ctrl) { IntPtr hOldWnd = GetCapture...
代码如下:
class WinAPI
{
[DllImport("coredll.dll")]
private static extern IntPtr SetCapture(IntPtr hWnd);
[DllImport("coredll.dll")]
private static extern IntPtr GetCapture();
public static IntPtr GetHWnd(Control ctrl)
{
IntPtr hOldWnd = GetCapture();
ctrl.Capture = true;
IntPtr hWnd = GetCapture();
ctrl.Capture = false;
SetCapture(hOldWnd);
return hWnd;
}
}