
08.10.2010, 14:28
|
 |
Let Me Show You
|
|
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
|
|
1. выводятся экранные координаты окна:
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Mask;
type
TForm1 = class(TForm)
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
MaskEdit1: TMaskEdit;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Types;
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
var
hid, h: THandle;
data: array [0..$ff] of Char;
l: Integer;
rct: TRect;
p: TPoint;
begin
Label1.Caption:='';
Label2.Caption:='';
Label3.Caption:='';
begin
hid:=GetForegroundWindow;
AttachThreadInput(GetCurrentThreadId, GetWindowThreadProcessId(hid, nil), True);
h:=GetFocus;
if h>0 then
begin
l:=GetClassName(h, data, $100);
if l>0 then Label1.Caption:=Copy(data, 1, l);
if Windows.GetClientRect(h, rct) then
begin
p.X:=rct.Left;
p.Y:=rct.Top;
Windows.ClientToScreen(h, p);
Label2.Caption:=IntToStr(p.X)+','+IntToStr(p.Y)+'/'+IntToStr(rct.Right)+','+IntToStr(rct.Bottom);
end;
l:=GetWindowText(h, data, $100);
if l>0 then Label3.Caption:=Copy(data, 1, l);
end;
AttachThreadInput(GetCurrentThreadId, GetWindowThreadProcessId(hid, nil), False);
end;
end;
end.
2. это и так то окно, в которое посылаются клавиатурные сообщения. по классу окна можно предположить о том, что это за окно, например EDIT, BUTTON, STATIC
__________________
Пишу программы за еду.
__________________
|