📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
procedure WMHotKeyHandle(var Msg: TMessage); message WM_HotKey;
//消息处理声明
public
{ Public declarations }
end;
var
Form1: TForm1;
HotKeyID : Integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
HotKeyVK : Integer;
HotKeyMOD : Integer;
begin
HotKeyVK := Ord('1');
HotKeyMOD:= MOD_ALT;
HotKeyID := GlobalAddAtom(PChar(Application.Title)) - $C000;
if not RegisterHotKey(self.Handle, HotKeyID, HotKeyMOD, HotKeyVK) then
begin
//如果失败
UnRegisterHotKey(Handle, HotKeyID);
DeleteAtom(HotKeyID);
end;
end;
//消息处理
procedure TForm1.WMHotKeyHandle(var Msg: TMessage);
begin
if (Msg.LParamHi = Ord('1')) and (Msg.LParamLo = MOD_ALT) then
begin
if IsIconic(Application.Handle) then
Application.restore
else
Application.BringToFront;
end;
end;
//释放
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
UnRegisterHotKey(self.Handle, HotKeyID);
DeleteAtom(HotKeyID);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -