Win32 API:FindWindowEx
EnumChildWindows
....

解决方案 »

  1.   

    Function GetURL(H:hwnd;lparam:longint):boolean;stdcall;
    var str,url:array [0..254] of char;
    begin
        getclassname(h,@str,255);
        if strpas(@str)='ComboBoxEx32' then//在窗口上找某个控件如果不指定可枚举所有控件
          begin
          SendMessage(h,WM_GETTEXT,255,LongInt(@url));
          fmMain.ListBox1.Items.Add(strpas(@url));
          end;
          result:=true;
      end;function callbackproc(H:HWnd;lparam:longint):Boolean;stdcall;
    var str:array [1..255] of char;
    begin
      getclassname(h,@str,255);
      if ((strpas(@str)='CabinetWClass') or (strpas(@str)='IEFrame')) then  //设置你要得到什么样的窗口句柄
          begin
            Enumchildwindows(h,@GetURL,0);
          end;
          result:=true;
    end;procedure TfmMain.Button3Click(Sender: TObject);
    begin
    listbox1.Clear;
    Enumwindows(@callbackproc,0);
    end;
      

  2.   

    找某个窗体的子控件。function EnumChild(hwnd: THandle; Param: Integer): Boolean; stdcall;
    var
      C: array [0..255] of Char;
      Memo: TMemo;
    begin
      Memo := TMemo(Param);
      FillChar(C, SizeOf(C), 0);
      if GetClassName(hwnd, C, SizeOf(C)) > 0 then
      begin
        Memo.Lines.Add(Format('Child Handle: %d, classname: %s', [hwnd, C]));
        FillChar(C, SizeOf(C), 0);
        if (GetWindowText(hwnd, C, SizeOf(C)) > 0) and (StrLen(C) > 0) then
          Memo.Lines.Add('it''s text is :' + C);
      end;
      Result := True;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      //Handle给自已,你可以FindWindow找,或用EnumWindows的方法,像这种一样找出其它窗体。
      EnumChildWindows(Handle, @EnumChild, Integer(Memo1));
    end;