我有一个主窗口,它有一个TEdit和一个需要句柄的TButton。它们都在TPanel中。到目前为止我的代码是
public void SendPacket(string packet)
{
IntPtr hWnd = Window.FindWindow(null, "AlissaAnalyzer");
IntPtr panel = Window.FindWindowEx(hWnd, IntPtr.Zero, "TPanel", "");
IntPtr edithWnd = Window.FindWindowEx(panel, IntPtr.Zero, "TEdit", "");
IntPtr buttonhWnd = Window.FindWindowEx(panel, IntPtr.Zero, "TButton", "");
//Do stuff with handles
}这为我提供了TPanel和TButton的句柄,但TEdit的句柄为0。我不知道为什么它不能工作,因为它遵循Spy++给我的结构:

我是不是漏掉了什么?我需要一个不同的方法来获取TEdit的句柄吗?我是不是用错了FindWindowEx?
发布于 2012-01-02 13:04:28
Spy++显示编辑框中没有文本。奇怪的是,即使是tButton也没有标题。第一次查找编辑应该可以,但是根据您的另一个问题,一旦您向tEdit发送了一些文本,FindWindowEx调用就会失败,因为您总是将"“作为文本传递。您可以通过传递null来查找任何匹配项。
https://stackoverflow.com/questions/8697178
复制相似问题