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;
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;
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;
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);
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);
什么值啊,直接写就可以了formx.edit2....
如句柄为: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;