当编辑框有多个时如何获取hWnd?

发布于 2024-12-23 10:30:03 字数 322 浏览 2 评论 0原文

我有一个不属于我的程序,它有 3 个 TEdit 框和 3 个 TButton 对象。我可以通过使用轻松获取按钮句柄:

IntPtr buttonhwnd = FindWindowEx(mainhwnd, IntPtr.Zero, "TButton", "Button Text");

但我无法对编辑框执行相同的操作,因为它们中没有任何文本。因此 FindWindowEx(hWnd, IntPtr.Zero, "TEdit", "") 可以获取所有这些。然而,它只得到它遇到的第一个,而我需要最后一个。有没有办法跳过多个框或区分它们?

I have a program that is not mine that has 3 TEdit boxes and 3 TButton objects. I can easily get the button handles by using:

IntPtr buttonhwnd = FindWindowEx(mainhwnd, IntPtr.Zero, "TButton", "Button Text");

But I can't do the same with the Edit boxes since they don't have any text in them. Therefore FindWindowEx(hWnd, IntPtr.Zero, "TEdit", "") can get all of them. However, it only gets the first one it comes across and I need the last one. Is there a way to skip a number of boxes or differentiate between them?

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

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

发布评论

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

评论(1

随遇而安 2024-12-30 10:30:03

我找到了答案:

鉴于有 3 个控件,我可以使用:

//Get first occuring Edit box
IntPtr edithWnd = FindWindowEx(mainhWnd, IntPtr.Zero, "TEdit", "");
//And the second
edithWnd = FindWindowEx(mainhWnd, edithWnd, "TEdit", "");
//And finally the one I want
edithWnd = FindWindowEx(mainhWnd, edithWnd, "TEdit", "");

虽然不是动态的,但它可以为我完成工作。然而,为了将来可能需要这个的人参考:除了知道他们所处的 Z 位置之外,还有什么方法可以区分他们吗?

I found the answer:

Given there are 3 controls, I can use:

//Get first occuring Edit box
IntPtr edithWnd = FindWindowEx(mainhWnd, IntPtr.Zero, "TEdit", "");
//And the second
edithWnd = FindWindowEx(mainhWnd, edithWnd, "TEdit", "");
//And finally the one I want
edithWnd = FindWindowEx(mainhWnd, edithWnd, "TEdit", "");

Although not dynamic, it gets the job done for me. However, for future reference for people who might need this: Is there a way to differentiate between them besides knowing what Z position they're in?

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