读取具有多个同名类的子控件?

发布于 2024-11-09 16:19:20 字数 1303 浏览 0 评论 0 原文

我目前正在尝试获取控件的文本,当从顶部窗口向下到我需要的控件时,我陷入了这个控件中,该控件有多个子字段,其中两个控件具有相同的类名。

调试示例代码如图所示:

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, IntPtr.Zero, "My_SplitterWindow", null);
iData.Text += control2.ToString("X") + Environment.NewLine;

IntPtr control3 = FindWindowEx(control2, IntPtr.Zero, "ATL:0061FA08", null);
iData.Text += control3.ToString("X") + Environment.NewLine;

IntPtr control4 = FindWindowEx(control3, IntPtr.Zero, "ATL:0061E168", null);
iData.Text += control4.ToString("X") + Environment.NewLine;

IntPtr control5 = FindWindowEx(control4, IntPtr.Zero, "ATL:00620118", null);
iData.Text += control5.ToString("X") + Environment.NewLine;

IntPtr control6 = FindWindowEx(control5, IntPtr.Zero, "ATL:00622208", null);
iData.Text += control6.ToString("X") + Environment.NewLine;

// stucked here... :/

这是我现在所在的子控件的图像: 具有多个控件的子控件

我需要来自 ATL:00622208 的第二个控件< code>#32770 (Dialog) 但是如何使用 FindWindowEx 只读取第二个控件以移动到下一个控件?

I am currently trying to get the text of a control and while going down from the top window to the control I needed I got stuck in this control which has multiple chield with 2 controls having the same class name.

Debug sample code as illustration:

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, IntPtr.Zero, "My_SplitterWindow", null);
iData.Text += control2.ToString("X") + Environment.NewLine;

IntPtr control3 = FindWindowEx(control2, IntPtr.Zero, "ATL:0061FA08", null);
iData.Text += control3.ToString("X") + Environment.NewLine;

IntPtr control4 = FindWindowEx(control3, IntPtr.Zero, "ATL:0061E168", null);
iData.Text += control4.ToString("X") + Environment.NewLine;

IntPtr control5 = FindWindowEx(control4, IntPtr.Zero, "ATL:00620118", null);
iData.Text += control5.ToString("X") + Environment.NewLine;

IntPtr control6 = FindWindowEx(control5, IntPtr.Zero, "ATL:00622208", null);
iData.Text += control6.ToString("X") + Environment.NewLine;

// stucked here... :/

Here is an image of the child control I am at right now:
child control with multiple controls

I need from ATL:00622208 exactly the 2nd control #32770 (Dialog) but how do I read only the second one using FindWindowEx to move to the next control ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

饮湿 2024-11-16 16:19:20

一旦你有了窗口句柄“IntPtr”,你就可以得到子窗口的列表,如下所示...

IntPtr window = FindWindowEx("MainControl", "WindowTitle");

IntrPtr child = GetWindow(window, GW_CHILD | GW_HWNDFIRST);
while(child != IntPtr.Zero)
{
     child = GetWindow(child, GW_HWNDNEXT);
}

你可以从 此处

Once you have the window handle 'IntPtr' you can get the list of child windows like this...

IntPtr window = FindWindowEx("MainControl", "WindowTitle");

IntrPtr child = GetWindow(window, GW_CHILD | GW_HWNDFIRST);
while(child != IntPtr.Zero)
{
     child = GetWindow(child, GW_HWNDNEXT);
}

You can find the pinvoke needed for the Win32 GetWindow from here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文