怎样列出某窗口下所有Edit控件~有源码给分?假设已知某程序A的某窗口的Captain属性为“ABC”
怎样通过另一个程序B列出程序A的该窗口下所有Edit控件

解决方案 »

  1.   

    for I := 0 to ControlCount - 1 do
    begin
      if Controls[I] is TEdit then....
      

  2.   

    可以看一下 WINSIGHT32.EXE 里面列出了所有的用户程序的信息 用SPY++也行
      

  3.   

    for I := 0 to ControlCount - 1 do
    begin
      if Controls[I] is TEdit then
    DWGZ已经给出答案了
      

  4.   

    for I:=0 to Screen.FormCount-1 do 
      if (Screen.Forms[I] as TForm).Caption='ABC' then
        for J:=0 to Application.ComponentCount-1 do 
          if (Application.Components[J] is TEdit) and (((Application.Components[J] as TEdit)).Parent=Screen.Forms[I] as TForm) then
            ShowMessage('Found One!');
      

  5.   

    function uhwGetClassName(const hWindow: HWND): WideString;
    var
      a: array[0..255] of AnsiChar;
    begin
      Result := '';
      if hWindow <= 0 then Exit;
      if not IsWindow(hWindow) then Exit;  GetClassNameA(hWindow, @a, SizeOf(a));
      Result := WideString(PAnsiChar(@a));
    end;var
      sList: TStrings;procedure GetEditHwnds(hWindow: THandle; OutList: TStrings);  function ECWPEdits(h: HWND; lPar: LPARAM): LongBool; stdcall;
      var
        s: string;
      begin
        Result := True;
        s := uhwGetClassName(h);
        if SameText(s, 'Edit') or SameText(s, 'TEdit') then
          sList.Add(IntToStr(h));
      end;begin
      sList := OutList;
      EnumChildWindows(hWindow, @ECWPEdits, 0);
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
      h: THandle;
      OutList: TStrings;
    begin
      h := FindWindow(nil, 'ABC');
      if h = 0 then Exit;  OutList := TStringList.Create;
      try
        GetEditHwnds(h, OutList);
        ListBox1.Clear;
        ListBox1.Items.AddStrings(OutList);
      finally
        OutList.Free;
      end;
    end;
    -------------------------------
    风过西窗客渡舟船无觅处
    年年一川新草遥看却似旧