【发布时间】:2015-08-17 17:52:47
【问题描述】:
您好,我正在尝试处理外部程序中的控件。我可以获取主窗体句柄,然后是面板句柄,但无法确定我正在获取哪个面板,因为有 4 个面板显示使用 spy++
我知道我是否可以通过使用实例来选择面板,这将允许我选择我想要的面板。我要选择TPanel3。
Dim destination As IntPtr = FindWindow("TDeviceMainForm", "Gem")
If destination Then MessageBox.Show("destination")
Dim destControlpnl As IntPtr = FindWindowEx(destination, Nothing, "TPanel", Nothing)
destControlpnl = FindWindowEx(destination, Nothing, "TPanel", Nothing)
If destControlpnl Then MessageBox.Show("destControlpnl")
Dim destControl As IntPtr = FindWindowEx(destControlpnl, Nothing, "TPanel", Nothing)
If destControl Then MessageBox.Show("destControl")
【问题讨论】:
-
不会是
TPanel3。它将是一个类名称为TPanel和窗口名称为Panel3的控件。我猜。通过询问具有该类名称和窗口名称的控件,您会很容易找到它。 -
控件的命名约定表明正在使用 VCL 框架。如果这是真的,VCL 用户通常会清除
TPanel.Caption属性,在这种情况下,将没有可检索的窗口名称。如果“Panel3”在 Spy++ 中不可见,则无法通过 Win32 API 访问。 -
大家好,谢谢你们,这对我帮助很大:-)
标签: .net vb.net visual-studio winapi spy++