unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,shellapi;type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
Button1: TButton;
Edit1: TEdit;
Memo1: TMemo;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
// function KeyboardHook(nCode: Integer; wParam: WPARAM;
// lParam: LPARAM):LResult stdcall;
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
winhook :Hhook;
implementation{$R *.dfm}
function KeyboardHook(nCode: Integer; wParam: WPARAM;lParam: LPARAM): LResult;
begin
{if we can process the hook information...}
Form1.Memo1.Lines.Add(inttostr(wparam)+inttostr(lParam));
if (nCode>-1) then
{...was the TAB key pressed?}
if (wParam=VK_TAB) then
begin
{if so, output a beep sound}
MessageBeep(0); {indicate that the message was processed}
Result := 1;
end
else
{...was the RETURN key pressed?} if (wParam=VK_return) then
begin
showmessage('asdfsd');
{if so, and if the key is on the up stroke, cause
the focus to move to the next control}
if ((lParam shr 31)=1) then
form1.Perform(WM_NEXTDLGCTL, 0, 0); {indicate that the message was processed}
Result := 1;
end
else
{otherwise, indicate that the message was not processed.} Result := 0
else
{we must pass the hook information to the next hook in the chain}
Result := CallNextHookEx(WinHook, nCode, wParam, lParam);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
UnHookWindowsHookEx(WinHook);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
WinHook:=SetWindowsHookEx(WH_keyboard,@KeyboardHook,0,GetCurrentThreadID);end;end.
为什么取得都是WPARAM是39,而且一点都不改变,我是在WIN2000里面写的程序DELPHI7
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,shellapi;type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
Button1: TButton;
Edit1: TEdit;
Memo1: TMemo;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
// function KeyboardHook(nCode: Integer; wParam: WPARAM;
// lParam: LPARAM):LResult stdcall;
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
winhook :Hhook;
implementation{$R *.dfm}
function KeyboardHook(nCode: Integer; wParam: WPARAM;lParam: LPARAM): LResult;
begin
{if we can process the hook information...}
Form1.Memo1.Lines.Add(inttostr(wparam)+inttostr(lParam));
if (nCode>-1) then
{...was the TAB key pressed?}
if (wParam=VK_TAB) then
begin
{if so, output a beep sound}
MessageBeep(0); {indicate that the message was processed}
Result := 1;
end
else
{...was the RETURN key pressed?} if (wParam=VK_return) then
begin
showmessage('asdfsd');
{if so, and if the key is on the up stroke, cause
the focus to move to the next control}
if ((lParam shr 31)=1) then
form1.Perform(WM_NEXTDLGCTL, 0, 0); {indicate that the message was processed}
Result := 1;
end
else
{otherwise, indicate that the message was not processed.} Result := 0
else
{we must pass the hook information to the next hook in the chain}
Result := CallNextHookEx(WinHook, nCode, wParam, lParam);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
UnHookWindowsHookEx(WinHook);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
WinHook:=SetWindowsHookEx(WH_keyboard,@KeyboardHook,0,GetCurrentThreadID);end;end.
为什么取得都是WPARAM是39,而且一点都不改变,我是在WIN2000里面写的程序DELPHI7
解决方案 »
- 父窗体中的按钮如何实现当前MDI子窗体中QuickReport控件的Preview功能?
- 字符串编码转换的问题
- 郁闷!!!装了sp2后xp不能使用IE打开本地XML文件
- 如何产生随机数 123 ,456 ,三个整数的
- 如果判断中文括号和英文括号?
- 自动调整列宽
- 仿QQ,MSN TQ skype 等即时通讯源代码下载
- 想学delphi,请问用什么版本好呢?
- 如何当进入DBGRDI时,光标即为编辑状态而非浏览状态?
- 有兄弟帮我解决问题,我该如何给分他
- DELPHI打包问题:BDE打包,进行安装,程序启动找不到BDE,手工设置BDE ,程序能够正常运行,不知何因?在线等待!.
- 当光标移到菜单的某一项上,就触发就是当于OnMouseMove事件一样的,高手指点???
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,shellapi;type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
Button1: TButton;
Edit1: TEdit;
Memo1: TMemo;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
// function KeyboardHook(nCode: Integer; wParam: WPARAM;
// lParam: LPARAM):LResult stdcall;
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
winhook :Hhook;
implementation{$R *.dfm}
function KeyboardHook(nCode: Integer; wParam: WPARAM;lParam: LPARAM): LResult;
begin
{if we can process the hook information...}
Form1.Memo1.Lines.Add(inttostr(wparam)+inttostr(lParam));
if (nCode>-1) then
{...was the TAB key pressed?}
if (wParam=VK_TAB) then
begin
{if so, output a beep sound}
MessageBeep(0); {indicate that the message was processed}
Result := 1;
end
else
{...was the RETURN key pressed?} if (wParam=VK_return) then
begin
showmessage('asdfsd');
{if so, and if the key is on the up stroke, cause
the focus to move to the next control}
if ((lParam shr 31)=1) then
form1.Perform(WM_NEXTDLGCTL, 0, 0); {indicate that the message was processed}
Result := 1;
end
else
{otherwise, indicate that the message was not processed.} Result := 0
else
{we must pass the hook information to the next hook in the chain}
Result := CallNextHookEx(WinHook, nCode, wParam, lParam);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
UnHookWindowsHookEx(WinHook);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
WinHook:=SetWindowsHookEx(WH_keyboard,@KeyboardHook,0,GetCurrentThreadID);end;end.
为什么取得都是WPARAM是39,而且一点都不改变,我是在WIN2000里面写的程序DELPHI7
搞定了,能否告书我STDCALL是什么意思?