I'm trying to access a third party application's "Text Boxes" using delphi programming so I need to find the handle of each "Text Box" using FindWindowEx(...) function .
The problem is , as all text boxes have the same class name with "NO window name" this function can just give me the first TextBOx handle !
How can I get the rest of text boxes handles while they have no names ?
Thanks in advance.
You can use EnumChildWindows
to enumerate all child windows of the third party application's window and test the class name of each enumerated window to see if it is the "Text Box" class. Example:
function EnumChildren(hwnd: HWND; lParam: LPARAM): BOOL; stdcall;
const
TextBoxClass = 'EDIT'; (?)
var
ClassName: array[0..259] of Char;
begin
Result := True;
GetClassName(hwnd, ClassName, Length(ClassName));
if ClassName = TextBoxClass then
TStrings(lParam).Add(IntToHex(hwnd, 8));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Clear;
EnumChildWindows(OtherAppWnd, @EnumChildren, UINT_PTR(Memo1.Lines));
end;