相关疑难解决方法(0)

C#通过名称和序号使用FindWindowEx获取子句柄

根据http://msdn.microsoft.com/en-us/library/ms633500(v=vs.85).aspx我定义了FindWindowEx函数.

using System.Runtime.InteropServices;

[DllImport("user32.dll", CharSet=CharSet.Unicode)]
static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle); 
Run Code Online (Sandbox Code Playgroud)

现在我能够找到第一个 "Button"控件的句柄(从Spy ++获取名称),将childAfter设置为IntPtr.Zero.

IntPtr hWndParent = new IntPtr(2032496);  // providing parent window handle
IntPtr hWndButton = FindWindowEx(hWndParent, IntPtr.Zero, "Button", string.Empty);
Run Code Online (Sandbox Code Playgroud)

如何在父窗口中获取"Button"控件的第二个,第三个或任何句柄?事实是,按钮标题可能会有所不同,所以我无法通过名称定义第四个参数直接找到它们.

c# winapi handle spy++ visual-c++

5
推荐指数
1
解决办法
4万
查看次数

标签 统计

c# ×1

handle ×1

spy++ ×1

visual-c++ ×1

winapi ×1