unit1.pas

来自「delphi写的一键隐藏窗体源码,按下f12就能隐藏当前窗体」· PAS 代码 · 共 57 行

PAS
57
字号
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  h:thandle;
implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
if getasynckeystate(35)<>0 then
begin
messagebox(0,'程序已退出','提示',mb_ok);
close;
end;


if getasynckeystate(123)<>0 then
begin
h := GetForegroundWindow;
SetWindowPos(h,0,100,100,100,100,SWP_HIDEWINDOW or SWP_NOSIZE or SWP_NOMOVE);
end;

if getasynckeystate(122)<>0 then
begin
SetWindowPos(h,0,100,100,100,100,SWP_SHOWWINDOW or SWP_NOSIZE or SWP_NOMOVE);
end;
form1.AlphaBlendValue:=0;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
timer1.Interval:=50;
SetWindowLong(Application.Handle,GWL_EXstyle,WS_EX_TOOLWINDOW);
messagebox(0,'F12隐藏程序,F11还原','提示',mb_ok);
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?