欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

獲得.net控件的windows句柄的方法

 更新時間:2013年04月15日 10:30:01   作者:  
有一個簡單的獲得控件的句柄的竅門。你將窗體設(shè)置為鼠標(biāo)可捕獲,那么你的窗口句柄可以通過使用Windows API捕獲。 這個想法在以下的GetHWnd函數(shù)中實現(xiàn):

復(fù)制代碼 代碼如下:

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;
  }
}

    

相關(guān)文章

最新評論