DLL을 동반하지 않고 포커스가 없을때도 특정 키보드 명령을 받는 방법입니다.

RegisterHotKey, UnRegisterHotKey 2개의 함수로 제공되며, 등록을 한 프로그램이 죽으면 자동적으로 핫키가 해제됩니다.

아래는 예제입니다. 첨부파일읋 실행한 후 Control + F3 을 누르면 메시지창이 뜹니다.

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    등록: TSpeedButton;
    해제: TSpeedButton;
    procedure 등록Click(Sender: TObject);
    procedure 해제Click(Sender: TObject);
  public
    procedure WMHotKey(var Message: TMessage); message WM_HOTKEY;
  end;
var
  Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.WMHotKey(var Message: TMessage);
begin
  case Message.WParam of
    100 : begin
      FormStyle := fsStayOnTop;
      ShowMessage('단축키 Control + F3  이 실행되엇습니다');
      FormStyle := fsNormal;
    end;
  end;
end;

procedure TForm1.등록Click(Sender: TObject);
var
  isRegisterd : Boolean;
begin
  isRegisterd := RegisterHotKey(Handle, 100, MOD_CONTROL, VK_F3); //Control + F3
  if not isRegisterd then ShowMessage('등록실패');
end;

procedure TForm1.해제Click(Sender: TObject);
begin
  UnregisterHotKey(Handle, 100);
end;

end.
분류 :
Win32
조회 수 :
19594
등록일 :
2008.10.24
12:13:52 (*.149.217.155)
엮인글 :
http://www.lunapiece.net/981/81b/trackback
게시글 주소 :
http://www.lunapiece.net/981
문서 첨부 제한 : 0Byte/ 10.00MB
파일 제한 크기 : 10.00MB (허용한 확장자만 첨부할 수 있습니다.(관리자는 제외) : *.*)
옵션 :
:
:
:
:
List of Articles
번호 제목 글쓴이 날짜 조회 수
41 Win32 Windows에서 패킷스니핑 할 때 주의할점 Lyn 2009-12-15 11575
40 Win32 Process가 Open 한 Port 보는 프로그램 Lyn 2009-12-15 9162
39 Win32 Vista 프로세스 Admin 권한 상승 여부 알아내기 Lyn 2009-12-09 13921
38 Win32 CreateCompatibleBitmap 사용시 주의할점 Lyn 2009-12-01 13052
37 Win32 IJL Intel Jpeg Library 사용시 주의할 점 Lyn 2009-11-26 13155
36 Win32 Edit 에서 원하는 위시로 캐럿 옮기기 Lyn 2009-09-24 11181
35 Delphi / BCB Delphi 2005~ 2009 IDE 를 Delphi7 스타일로 [1] Lyn 2009-09-07 10814
34 Pure C++ new , new [] 연산자 오버로딩 하기 Lyn 2009-08-12 11780
33 Pure C++ C++ 헤더 중복 방지하기 Lyn 2009-04-20 12701
32 Win32 SendMessage로 문자열 날리기(WM_COPYDATA) Lyn 2009-04-20 196544
31 Visual C++ Visual C++ 2008 Class Diagram file Lyn 2009-04-20 15407
30 Visual C++ 프로젝트 옵션에 따른 string wstring 자동변환 Lyn 2009-03-19 15572
29 Delphi / BCB C++ Builder 단독 실행파일 만들기 Lyn 2009-03-16 14551
28 Win32 메세지 처리시 WPARAM, LPARAM 타잎 차이 Lyn 2009-02-05 13090
27 Win32 DLL의 전역변수 충돌 피하는 꽁수 Lyn 2009-01-23 13157
26 Visual C++ 사용자 정의 메세지 핸들러 만들기 Lyn 2009-01-23 15319
» Win32 Global HotKey(전역 단축키) 사용하기 Lyn 2008-10-24 19594
24 Win32 내 프로그램에 다른 프로그램 내장하기. [1] Lyn 2008-10-08 16368
23 Visual C++ VC++에서 STL 의 성능이 만족스럽지 않은경우 Lyn 2008-09-27 18532
22 Visual C++ VC++(Native) 에서 C#(.net) 의 DLL 호출하기 Lyn 2008-09-27 20291

SITE LOGIN :)