<br>拦截消息处理过程 <br><br><br>program Project1;<br><br>uses<br>Forms, messages, wintypes, winprocs,<br>Unit1 in 'UNIT1.PAS' {Form1};<br><br>{$R *.RES}<br><br>var<br>OldWndProc: TFarProc;<br><br>function NewWndProc(hWndAppl: HWnd; Msg, wParam: Word;<br>lParam: Longint): Longint; export;<br>begin<br>NewWndProc := 0; { Default WndProc return value }<br><br><br>NewWndProc := CallWindowProc(OldWndProc, hWndAppl, Msg,<br>wParam, lParam);<br>end;<br><br>begin<br>Application.CreateForm(TForm1, Form1);<br>OldWndProc := TFarProc(GetWindowLong(Application.Handle,<br><br>GWL_WNDPROC));<br>SetWindowLong(Application.Handle, GWL_WNDPROC,<br>longint(@NewWndProc));<br>Application.Run;<br>end. <br><br><br><br>模拟按下某键,就是向某处发送消息。<br><br>让 WIN95 模拟按了一个按键,就向某窗体发送按键一样,例如按下 ENTER 或者 TAB 键,或者按 7 键<br>PostMessage(Object.Handle, WM_KEYDOWN, VK_TAB, 0);<br>{Object表示窗体名,WM_KEYDOWN是按下,VK_TAB是发送的按键}<br>PostMessage(edit1.Handle, WM_KEYDOWN, 55, 0);<br>{向edit1发送一个7字}