📄 clienttoscreenu.pas
字号:
unit ClientToScreenU;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure Memo1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
Coords: TPoint; // holds the point being converted
begin
{indicate the clicked coordinates relative to the child window}
Label1.Caption := 'Memo Coordinates: '+IntToStr(X)+', '+IntToStr(Y);
{convert these coordinates into screen coordinates}
Coords := Point(X, Y);
Windows.ClientToScreen(Memo1.Handle, Coords);
{display the clicked coordinates relative to the screen}
Label2.Caption := 'Screen Coordinates: '+IntToStr(Coords.X)+', '+
IntToStr(Coords.Y);
{convert the coordinates into window client coordinates}
Windows.ScreenToClient(Form1.Handle, Coords);
{display the clicked coordinates relative to the client area of the window}
Label3.Caption := 'Form Coordinates: '+IntToStr(Coords.X)+', '+
IntToStr(Coords.Y);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -