procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
begin
  for I := 0 to ComponentCount - 1 do    // Iterate
  begin
    if Components[i] is TButton then
      ShowMessage(TButton(Components[i]).Caption);
  end;    // for
end;

解决方案 »

  1.   

    用spy++要不试试这个:
    procedure TForm1.Timer1Timer(Sender: TObject);
    var
      str1:array [0..1024] of char;
      s1:pchar;
      n1:HWND;
      p1:Tpoint;
    begin
      Getcursorpos(p1);
      n1:=windowFromPoint(p1);  sendMessage(n1,WM_GETTEXT,1024,longint(@str1));
      edit1.Text:=string(str1);
      s1:=@str1;
      getClassName(n1,s1,1024);
      Edit2.Text :=s1;
    end;
      

  2.   

    对不起.也许我没有说的很清楚.我所说的并非是自己所写程序中的窗体,而是桌面上的一个窗体,比如就象qq炸弹似的能捕捉到qq那个发送窗体,但我现在需要的是比如qq号那个位置的值.先谢了
      

  3.   

    所显示出来的,并不是所有的控件,比如说是文本框,label控件等
      

  4.   

    用findwindowUnit
    Windows.PasSyntax
    FindWindow(
    lpClassName: PChar; {a pointer to a null terminated class name string}
    lpWindowName: PChar {a pointer to a null terminated window name string}
    ): HWND; {returns a handle to a window}Description
    FindWindow retrieves the handle of the top-level window with the specified class name and window name. Child windows are not searched.Parameters
    lpClassName: A pointer to a case sensitive, null-terminated string that specifies the class name, or an integer atom identifying the class name string. If this specifies an atom, the atom must be created with a call to GlobalAddAtom. The atom, a 16 bit value, must be in the low-order word of ClassName and the high-order word must be zero.lpWindowName: A pointer to a case sensitive, null-terminated string that specifies the windows name, which is the title in the caption bar. If this parameter is NIL, all window names match.Return Value
    If this function succeeds, the return value is the handle of the window with the specified class name and window name; otherwise it returns zero. To get extended error information, call the GetLastError function.The Tomes of Delphi 3: Win32 Core API Help File by Larry Diehl
    例如:
    Findwindow('ExploreWClass',nil);
      

  5.   

    用findwindowUnit
    Windows.PasSyntax
    FindWindow(
    lpClassName: PChar; {a pointer to a null terminated class name string}
    lpWindowName: PChar {a pointer to a null terminated window name string}
    ): HWND; {returns a handle to a window}Description
    FindWindow retrieves the handle of the top-level window with the specified class name and window name. Child windows are not searched.Parameters
    lpClassName: A pointer to a case sensitive, null-terminated string that specifies the class name, or an integer atom identifying the class name string. If this specifies an atom, the atom must be created with a call to GlobalAddAtom. The atom, a 16 bit value, must be in the low-order word of ClassName and the high-order word must be zero.lpWindowName: A pointer to a case sensitive, null-terminated string that specifies the windows name, which is the title in the caption bar. If this parameter is NIL, all window names match.Return Value
    If this function succeeds, the return value is the handle of the window with the specified class name and window name; otherwise it returns zero. To get extended error information, call the GetLastError function.The Tomes of Delphi 3: Win32 Core API Help File by Larry Diehl
    例如:
    Findwindow('ExploreWClass',nil);
      

  6.   

    某个控件的值???
    什么值啊,直接写就可以了formx.edit2....
      

  7.   

    获取了句柄还不好办啊?
    如句柄为:h
    var text:array[0..255] of char;
    begin
    getwindowtext(h,@text,255);
    sendmessage(h,wm_gettext,255,longint(@text));
    memo1.lines.add(text);
    end;
      

  8.   

    我只知道一个东西:application.title.取程序的标题
      

  9.   

    需要在窗体的uses单元上加上控件所在的窗体名字才能引用吧