function FindWindowEx2(hParent: HWND; ChildClassName:
string; ChildNr: Word): HWND;
var
i: Word;
hChild: HWND;
begin
hChild := 0;
Result := 0;
Dec(ChildNr);
for i := 0
to ChildNr
do
begin
hChild := FindWindowEx(hParent, hChild, PChar(ChildClassName),
nil);
if hChild = 0
then
Break;
Result := hChild;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
S:
String;
len : Integer;
wndMain, wndChild: HWND;
begin
wndMain := FindWindow('
TEditWindow','
Findcall.pas');
if wndMain <> 0
then
begin
wndChild := FindWindowEx(wndMain, 0, '
TPanel',
nil);
wndChild := FindWindowEx2(wndChild,'
TPanel', 2);
wndChild := FindWindowEx(wndChild, 0, '
TPanel',
nil);
wndChild := FindWindowEx(wndChild, 0, '
TPanel',
nil);
wndChild := FindWindowEx(wndChild, 0, '
TEditControl',
nil);
len := Sendmessage(wndChild, WM_GETTEXTLENGTH, 0, 0);
SetLength(S, len);
if wndChild <> 0
then
SendMessage(wndChild, WM_GETTEXT, len+1, lparam(@S[1]));
Label2.Caption := S;
end;
end;