S
suyude
Unregistered / Unconfirmed
GUEST, unregistred user!
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 }
public
procedure WMHotKey(var Message: TWMHOTKEY); message WM_HOTKEY;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
//注册ctrl+alt+z热键
RegisterHotKey(Handle, GlobalAddAtom('hotkey'), MOD_CONTROL+MOD_ALT, ord('Z'));
end;
procedure TForm1.WMHotKey(var Message: TWMHOTKEY);
begin
//按下热键所执行的事件{问,如果成功隐藏程序窗体以后,这里用什么代码激活程序界面呢?}
application.MessageBox('内容','标题',mb_ok);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
//在关闭时注销热键
UnregisterHotKey(Handle, GlobalAddAtom('hotkey'));
end;
end.
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 }
public
procedure WMHotKey(var Message: TWMHOTKEY); message WM_HOTKEY;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
//注册ctrl+alt+z热键
RegisterHotKey(Handle, GlobalAddAtom('hotkey'), MOD_CONTROL+MOD_ALT, ord('Z'));
end;
procedure TForm1.WMHotKey(var Message: TWMHOTKEY);
begin
//按下热键所执行的事件{问,如果成功隐藏程序窗体以后,这里用什么代码激活程序界面呢?}
application.MessageBox('内容','标题',mb_ok);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
//在关闭时注销热键
UnregisterHotKey(Handle, GlobalAddAtom('hotkey'));
end;
end.