如何解决读取具有多个具有相同名称的子类的子控件?
| 我目前正在尝试获取控件的文本,并从顶部窗口转到该控件时,我陷入了该控件的困境,该控件具有多个产量,而2个控件具有相同的类名。 调试示例代码,如下所示:IntPtr window = FindWindow(\"MainControl\",\"WindowTitle\");
iData.Text += window.ToString(\"X\") + Environment.NewLine;
IntPtr control = FindWindowEx(window,IntPtr.Zero,\"CMainWindow\",null);
iData.Text += control.ToString(\"X\") + Environment.NewLine;
IntPtr control2 = FindWindowEx(control,\"My_SplitterWindow\",null);
iData.Text += control2.ToString(\"X\") + Environment.NewLine;
IntPtr control3 = FindWindowEx(control2,\"ATL:0061FA08\",null);
iData.Text += control3.ToString(\"X\") + Environment.NewLine;
IntPtr control4 = FindWindowEx(control3,\"ATL:0061E168\",null);
iData.Text += control4.ToString(\"X\") + Environment.NewLine;
IntPtr control5 = FindWindowEx(control4,\"ATL:00620118\",null);
iData.Text += control5.ToString(\"X\") + Environment.NewLine;
IntPtr control6 = FindWindowEx(control5,\"ATL:00622208\",null);
iData.Text += control6.ToString(\"X\") + Environment.NewLine;
// stucked here... :/
这是我现在正在使用的子控件的图像:
我需要从ATL:00622208
到第二个控件#32770 (Dialog)
,但是如何使用FindWindowEx读取第二个控件以移至下一个控件?
解决方法
有了窗口句柄\'IntPtr \'后,您可以像这样获得子窗口的列表...
IntPtr window = FindWindowEx(\"MainControl\",\"WindowTitle\");
IntrPtr child = GetWindow(window,GW_CHILD | GW_HWNDFIRST);
while(child != IntPtr.Zero)
{
child = GetWindow(child,GW_HWNDNEXT);
}
您可以从此处找到Win32 GetWindow所需的pinvoke。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。