📄 mainunit.pas
字号:
unit mainunit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
procedure GetRectArea;
{ Public declarations }
end;
var
Form1: TForm1;
FormHandle:Hwnd;
FrmLeft,FrmTop,FrmRight,FrmBottom:Integer;
implementation
{$R *.dfm}
procedure JudgePointPosition(CurPoint:TPoint);
begin
if ((CurPoint.X >= FrmLeft) and (CurPoint.X <= Frmright) and
(CurPoint.Y >= FrmTop) and (CurPoint.Y <= FrmBottom)) then
begin
Form1.Show;
end
else
begin
Form1.hide;
end;
end;
procedure TForm1.GetRectArea;
var
rect:TRect;
begin
GetWindowRect(FormHandle,rect);
label1.Caption:='窗体左上角坐标:'+'('+Inttostr(rect.left)+','+Inttostr(rect.top)+')';
label2.Caption:='窗体右上角坐标:'+'('+Inttostr(rect.right)+','+Inttostr(rect.top)+')';
label3.Caption:='窗体左下角坐标:'+'('+Inttostr(rect.left)+','+Inttostr(rect.bottom)+')';
label4.Caption:='窗体右下角坐标:'+'('+Inttostr(rect.right)+','+Inttostr(rect.bottom)+')';
FrmLeft:=rect.left;
FrmTop:=rect.top;
FrmRight:=rect.right;
FrmBottom:=rect.bottom;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FormHandle:=Form1.Handle;
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
GetRectArea;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Timer1.Enabled:=False;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Timer1.Enabled:=True;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
P:TPoint;
begin
GetRectArea;
GetCursorPos(P);
Form1.label6.caption:='横坐标:'+InttoStr(P.x);
Form1.label7.caption:='纵坐标:'+InttoStr(P.y);
JudgePointPosition(P);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -