下面程序可捕获键盘如入,至于快捷键课做出相应的处理<br>unit Unit4;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm4 = class(TForm)<br> Button1: TButton;<br> procedure FormShow(Sender: TObject);<br> procedure Button1Click(Sender: TObject);<br> private<br> OldWndMeth, NewWndMeth: Pointer;<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form4: TForm4;<br> he:Thandle;<br><br>implementation<br><br>{$R *.DFM}<br><br>var<br> OldWndProc: Pointer = nil;<br><br>function NewWinProc (Handle: THandle;<br> Msg, wParam, lParam: LongInt): LongInt; stdcall;<br>begin<br> if Msg = wm_keydown then<br> begin<br> Beep;<br> SetWindowText (Handle,<br> PChar (Format (' %s', [char(lParam)])));<br> end;<br> // pass call to old window proc<br> Result := CallWindowProc (OldWndProc, Handle,<br> Msg, wParam, lParam);<br>end;<br><br>procedure TForm4.FormShow(Sender: TObject);<br>begin<br> he:=createwindow('edit','edit',ws_border or ws_visible or ws_child,10,10,<br> 100,40,handle,0,hinstance,0);<br>end;<br><br>procedure TForm4.Button1Click(Sender: TObject);<br>begin<br> OldWndProc := Pointer (SetWindowLong<br> (he, gwl_WndProc, LongInt (@NewWinProc)));<br>end;<br><br>end.<br>