hook?
解决方案 »
- 我想在捕捉到的视频画面上overlay出来一个小正方形的框 该怎么做?
- delphi package问题
- @string 和pchar(string) 区别
- Delphi访问Access的SQL语句中需访问外数据库库(ACCESS),如何加上外数据库的密码?
- 這麼晚了還有人在嗎?怎麼樣禁止CheckBox的點擊,不要用enabled=false
- ★★了散分,高兴一下
- 如何修改控制面板中的日期格式为'yyyy-mm-dd'?
- 队列问题
- 我想实现鼠标一移动就在当前位置给出坐标信息,该怎么办呀??(在桌面上也可以)
- 很迷惑的问题
- 请教怎么调用扫描仪!!!
- 高分求求网上即时语音传输源代码及相应的理论知识
可以拦截消息和函数做自己的处理。
一般都要用到SetWindowsHookEx这个API。例如拦截一个消息
{the prototype for the new keyboard hook function}
function KeyboardHook(nCode: Integer; wParam: WPARAM;
lParam: LPARAM): LResult; stdcall;var
Form1: TForm1;
WinHook: HHOOK; // a handle to the keyboard hook functionimplementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
begin {install the keyboard hook function into the keyboard hook chain}
WinHook:=SetWindowsHookEx(WH_KEYBOARD, @KeyboardHook, 0, GetCurrentThreadID);
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
{remove the keyboard hook function from the keyboard hook chain}
UnhookWindowsHookEx(WinHook);
end;function KeyboardHook(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LResult;begin
{if we can process the hook information...}
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
{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;