面对获得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窗口的对象