📄 unitform1.pas
字号:
unit unitForm1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure WmNCHitTest(var Msg: TWMNCHitTest); message WM_NCHITTEST;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
{ TForm1 }
procedure TForm1.WmNCHitTest(var Msg: TWMNCHitTest);
const v = 10; //border width
var p: TPoint;
begin
p := Point(Msg.XPos, Msg.YPos);
p := ScreenToClient(p);
if PtInRect(Rect(0, 0, v, v), p) then
Msg.Result := HTTOPLEFT
else if PtInRect(Rect(Width - v, Height - v, Width, Height), p) then
Msg.Result := HTBOTTOMRIGHT
else if PtInRect(Rect(Width - v, 0, Width, v), p) then
Msg.Result := HTTOPRIGHT
else if PtInRect(Rect(0, Height - v, v, Height), p) then
Msg.Result := HTBOTTOMLEFT
else if PtInRect(Rect(v, 0, Width - v, v), p) then
Msg.Result := HTTOP
else if PtInRect(Rect(0, v, v, Height - v), p) then
Msg.Result := HTLEFT
else if PtInRect(Rect(Width - v, v, Width, Height - v), p) then
Msg.Result := HTRIGHT
else if PtInRect(Rect(v, Height - v, Width - v, Height), p) then
Msg.Result := HTBOTTOM;
inherited;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Form1.Handle,
GWL_STYLE,
GetWindowLong(Handle, GWL_STYLE) and not WS_CAPTION);
Height := ClientHeight;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -