Delphi编写的一款锁屏小工具


本文整理自网络,侵删。

 
Delphi编写的一款锁屏小工具,双击程序立即锁屏,木有界面的。解除锁屏密码:alt+空格。
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Image1: TImage;
    Timer2: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    procedure HotKeyDown(var Msg: Tmessage); message WM_HOTKEY;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  FullScreen : Tbitmap;
  FullScreenCanvas : TCanvas;
  DC : HDC;
  HotKeyId: Integer;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  HotKeyId := GlobalAddAtom('MyHotKey') - $C000;
  RegisterHotKey(Handle, hotkeyid, MOD_ALT, VK_SPACE);
  FullScreen := Tbitmap.Create;
  FullScreen.Width := screen.Width;
  FullScreen.Height := Screen.Height;
  DC := GetDC(0);
  FullScreenCanvas := TCanvas.Create;
  FullScreenCanvas.Handle := DC;
  FullScreen.Canvas.CopyRect(Rect(0, 0, Screen.Width, Screen.Height), FullScreenCanvas, Rect(0, 0, Screen.Width, Screen.Height));
  FullScreenCanvas.Free;
  ReleaseDC(0, DC);
  Image1.Picture.Bitmap := FullScreen;
  image1.Width := FullScreen.Width;
  Image1.Height := FullScreen.Height;
  FullScreen.Free;
  //*****************************************

  Form1.Left := 0;
  Form1.Top := 0;
  Form1.Width := Screen.Width;
  Form1.Height := Screen.Height;
  Image1.Left := 0;
  Image1.Top := 0;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
 SetWindowPos(handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE);  //当前窗口置顶
end;

procedure TForm1.HotKeyDown(var Msg: Tmessage);
begin 
if (Msg.LparamLo = MOD_ALT) AND (Msg.LParamHi = VK_SPACE) then // 热键为ALT+空格
begin
    Application.Terminate;              //窗口结束
     UnRegisterHotKey(handle, HotKeyId); //释放热键资源
end;
end;
end.

相关阅读 >>

Delphi tdatetime 日期时间值的比较

Delphi三层开发小技巧:tclientdataset的delta妙用

Delphi http post json示例

关于如何发现Delphi程序的内存泄漏

Delphi判断exe文件是否正在运行的函数

Delphi timage保存图片到stream及从stream中取图片

Delphi gridpanel percent百分比设置

Delphi memo1文本搜索并高亮

Delphi2007-Delphi2010 程序不出现在任务栏的方法

Delphi 调整应用程序内存大小

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...