绝对可以用的,我试过的
//找出一给定窗口中指定的第几个某一类控件的句柄 //
//参数说明: WindowHandle:指定窗口的句柄 //
// ChildClass :该子控件的类名称(可指定部分) //
// ChildNo :该子控件是交窗口中的第几个此类控件 //
function GetChildHandle(WindowHandle: THandle; ChildClass: string; ChildNo: integer): THandle;
function EnumChildHandle(AHWnd: HWnd; LPARAM: lParam): boolean; stdcall;//回调函数
function GetChildHandle(WindowHandle: THandle; ChildClass: string; ChildNo: integer): THandle;
begin
ChildCnt := 0;
hChild := INVALID_HANDLE_VALUE;
sChildClassName := ChildClass;
SignChildNo := ChildNo;
EnumChildWindows(WindowHandle, @EnumChildHandle, 0);
result := hChild;
end;
function EnumChildHandle(AHWnd: HWnd; LPARAM: lParam): boolean; stdcall;
var
WndCaption, WndClass: array[0..254] of Char;
begin
result := True;
GetWindowText(AHWnd, @WndCaption, 254);
GetClassName(AHWnd, @WndClass, 254);
if pos(UpperCase(sChildClassName), UpperCase(WndClass)) > 0 then
begin
inc(ChildCnt);
if ChildCnt = SignChildNo then
begin
hChild := AHWnd;
Result := False;
end;
end;
end;
function IsWindowAppeared(sWinTitle: string; var hwnd: THandle): Boolean;
var
nTicks: DWORD;
begin
Result := False;
nTicks := GetTickCount;
repeat
if (GetTickCount - nTicks) > nTEN_SECONDS then Exit;
hwnd := GetThisWindow(sWinTitle);
until hwnd <> INVALID_HANDLE_VALUE;
Result := True;
end;
if IsWindowAppeared('IE窗口的标题', hParent) then
begin
hEdit := GetChildHandle(hParent, 'EDIT', n);//n 是你所要找的edit控件的个数,调用上面的函数就够了
end;