如何通过互操作性从WPF窗口获取滚动条的句柄?

时间:2018-07-18 13:15:55

标签: c# wpf interop

面对获得WPF窗口控制手柄的问题,对此有什么解决办法?

不确定以下步骤是否正确

[DllImport("user32.dll", EntryPoint = "GetWindow")]
public static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd);

//windowObj is the object of WPF window which contains the scroll bar
IntPtr windowHandle = new WindowInteropHelper(windowObj).Handle;
  if (windowHandle != IntPtr.Zero)
  {
     //GW_CHILD=5

     IntPtr hScroll = GetWindow(windowHandle, GW_CHILD);
     if (hScroll != IntPtr.Zero) // always getting 0
     {   
     }
  }

windowObj 是包含滚动条控件的WPF窗口的对象

0 个答案:

没有答案