티스토리 뷰

Programming/Delphi

Delphi - Hotkey

파란크리스마스 2008. 6. 23. 00:20
728x90

출처 : http://www.swissdelphicenter.ch/torry/showcode.php?id=147

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    id1 : Integer;
    procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WMHotKey(var Msg: TWMHotKey);
begin
 if Msg.HotKey = id1 then
   ShowMessage('Ctrl + A 선택!');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  // 키 등록 Ctrl + A 
  id1 := GlobalAddAtom('Hotkey1');
  RegisterHotKey(Self.Handle, id1, MOD_CONTROL, $41); // $41 -> A
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  // 키 해제
  UnRegisterHotKey(Handle, id1);
  GlobalDeleteAtom(id1);
end;

end.

댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함