📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormShow(Sender: TObject);
private
procedure WMSETTINGCHANGE(var Msg : TWMSETTINGCHANGE ); message WM_SETTINGCHANGE ;
procedure WMDisplayChange(var Msg : TWMDisplayChange ); message WM_DisplayChange ;
procedure ProperSize;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.ProperSize;
var R : TRect;
begin
SystemParametersInfo(SPI_GETWORKAREA,0,@R,0);
Top := R.Top + Round((R.Bottom - R.Top) / 4);
Left := R.Left + Round((R.Right - R.Left) / 4);
Height := R.Top + Round((R.Bottom - R.Top) / 2);
Width := R.Left + Round((R.Right - R.Left) / 2);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Propersize;
end;
procedure TForm1.WMSETTINGCHANGE(var Msg: TWMSETTINGCHANGE);
begin
if Msg.Flag and SPI_SETWORKAREA = SPI_SETWORKAREA then
begin
ShowMessage('WorkArea Changed so I have to resize...');
ProperSize;
end;
end;
procedure TForm1.WMDisplayChange(var Msg: TWMDisplayChange);
begin
ShowMessage('Display Changed so I have to resize...');
ProperSize;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -