获得.net控件的windows句柄的方法
时间:2021-01-08 12:21:39|栏目:.NET代码|点击: 次
复制代码 代码如下:
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;
}
}
栏 目:.NET代码
本文地址:http://www.codeinn.net/misctech/42372.html