根据我的研究,可以用列举子窗口的方式进行<br><br>function EnumChildWindowsProc(H: HWND; L: LPARAM): bool; stdcall;<br>var<br> ClassName: array[0..255] of char;<br> str2: string;<br>begin<br> GetClassName(H, @ClassName, 255);<br> str2 := ClassName;<br> if Form1.FClsName = str2 then<br> begin<br> Form1.FRetHWnd := H;<br> form1.MemoText.Lines.add(format('ID:%8d,CsName:%s', [h, str2]));<br> Result:=False;<br> end else<br> Result := True;<br>end;<br><br>function TForm1.FindCenterTree(const sCharacter,sClassName: string): HWND;<br>var//窗口标题特征串,要查找的控件类名<br> hCurrWnd,hParent: HWnd;<br> szText: array[0..254] of char;<br>begin<br> Form1.FRetHWnd := 0;<br> Form1.FClsName := sClassName;<br> hParent := 0;<br> hParent := GetWindow(Handle, GW_HWNDFIRST);<br> while hCurrWnd <> 0 do<br> begin<br> if GetWindowText(hParent, @szText, 255) > 0 then<br> if Pos(sCharacter, StrPas(szText)) > 0 then<br> begin<br> Memo1.Lines.Add(Format('ID:%8d, Caption:%s', [hCurrWnd, StrPas(@szText)]));<br> Break;<br> end;<br> hParent := GetWindow(hParent, GW_HWNDNEXT);<br> end;<br> if hParent <> 0 then<br> EnumChildWindows(hParent, @EnumChildWindowsProc, 0);<br><br> Result := Form1.FRetHWnd;<br>end;<br><br>在EnumChildWindowsProc中对ClassName进行直接比较时会出错,所以用窗口算定义属性却不会出错,也不知道为什么。