Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[7367] [답변] KNK300/ 어떤 특정키 데이타를 받지 않을수 있나
박테리아 [ ] 672 읽음    2000-09-26 14:01
안녕 하세요?

BacTeria 박종민 입니다.

키보드의 키를 가로 채려면 WM_HOTKEY 메시지를 이용하면 됩니다.

아래의 코드는 Enter 키를 '7'로 대체하는 코드입니다. 윈도우 전체에서...

VK_RETURN 대신에 다른 VK_... 키들을 넣어보세요.

이만... 박종민...

--------------------------------------------------------------------------------
unit Unit1;

interface

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

type
  TMainForm = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY;
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;

implementation

{$R *.DFM}

procedure SimulateKeyDown(V_Key: Byte);
begin
  Keybd_Event(V_Key, MapVirtualKey(V_Key, 0), 0, 0);
end;

procedure SimulateKeyUP(V_Key: Byte);
begin
  Keybd_Event(V_Key, MapVirtualKey(V_Key, 0), KEYEVENTF_KEYUP, 0);
end;

procedure TMainForm.WMHotKey(var Msg: TWMHotKey);
begin
  Case Msg.HotKey of
    101: begin
           SimulateKeyDown(Ord('7'));
           SimulateKeyUp(Ord('7'));
         end;
  end;
end;

procedure TMainForm.FormCreate(Sender: TObject);
begin
  RegisterHotKey(Handle, 101, 0, VK_RETURN);
end;

procedure TMainForm.FormDestroy(Sender: TObject);
begin
  UnRegisterHotKey(Handle, 101);
end;

end.


+ -

관련 글 리스트
7367 [답변] KNK300/ 어떤 특정키 데이타를 받지 않을수 있나 박테리아 672 2000/09/26
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.