在qq的聊天窗口,当按下"发送"按钮之前,执行一段我的代码
希望能用全局消息钩子加子类化函数实现
WH_CALLWNDPROC setwindowslong
因为,用全局钩子消息,我已会 我在学子类化函数的用法? library TmHook; uses
SysUtils,
Classes,
Windows,
Messages,
CommCtrl;
var
hhook: Windows.HHOOK;
hwndListView: HWND;
na:array[0..300] of char;
oldWndProc: Integer;
{$R *.res}
function WindowProc(hwnd: HWND; msg: UINT; wp: WPARAM; lp: LPARAM): LRESULT; stdcall;
begin
case Msg of
WM_LBUTTONDOWN:
MessageBox(hwndListView,'你好!','提示',MB_OK);
end;
Result := CallWindowProc(TFNWndProc(oldWndProc), hwnd, msg, wp, lp);
end;
function TmHookProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): Integer; stdcall;
var
cwp: PCwpStruct;
m:TPoint;
begin
Result := 0;
if (nCode < 0) then
begin
Result := CallNextHookEx(hhook, nCode, wParam, lParam);
exit;
end;
cwp := PCwpStruct(lParam);
if cwp^.message <> WM_COMMAND then
begin
Result := CallNextHookEx(hhook, nCode, wParam, lParam);
exit;
end;
GetCursorPos(m);
GetWindowText(WindowFromPoint(m),na,299);
if lstrcmpi('发送(S)',na) <>0 then
begin
Result := CallNextHookEx(hhook, nCode, wParam, lParam);
exit;
end;
hwndListView:=WindowFromPoint(m);
oldWndProc := SetWindowLong(hwndListView, GWL_WNDPROC, Integer(@WindowProc));
end;
procedure Hook(bEnable: Boolean); stdcall; export;
begin
if bEnable then
begin
if hhook = 0 then
begin
hhook := SetWindowsHookEx(WH_CALLWNDPROC, TmHookProc, HInstance, 0);
end;
end
else
begin
if hhook <> 0 then
begin
UnhookWindowsHookEx(hhook);
hhook := 0;
end;
end;
end;
exports
Hook;
begin
hhook := 0;
hwndListView := 0;
oldWndProc:=0;
end.
到底哪里错了,一运行,qq就自动关闭??
希望能用全局消息钩子加子类化函数实现
WH_CALLWNDPROC setwindowslong
因为,用全局钩子消息,我已会 我在学子类化函数的用法? library TmHook; uses
SysUtils,
Classes,
Windows,
Messages,
CommCtrl;
var
hhook: Windows.HHOOK;
hwndListView: HWND;
na:array[0..300] of char;
oldWndProc: Integer;
{$R *.res}
function WindowProc(hwnd: HWND; msg: UINT; wp: WPARAM; lp: LPARAM): LRESULT; stdcall;
begin
case Msg of
WM_LBUTTONDOWN:
MessageBox(hwndListView,'你好!','提示',MB_OK);
end;
Result := CallWindowProc(TFNWndProc(oldWndProc), hwnd, msg, wp, lp);
end;
function TmHookProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): Integer; stdcall;
var
cwp: PCwpStruct;
m:TPoint;
begin
Result := 0;
if (nCode < 0) then
begin
Result := CallNextHookEx(hhook, nCode, wParam, lParam);
exit;
end;
cwp := PCwpStruct(lParam);
if cwp^.message <> WM_COMMAND then
begin
Result := CallNextHookEx(hhook, nCode, wParam, lParam);
exit;
end;
GetCursorPos(m);
GetWindowText(WindowFromPoint(m),na,299);
if lstrcmpi('发送(S)',na) <>0 then
begin
Result := CallNextHookEx(hhook, nCode, wParam, lParam);
exit;
end;
hwndListView:=WindowFromPoint(m);
oldWndProc := SetWindowLong(hwndListView, GWL_WNDPROC, Integer(@WindowProc));
end;
procedure Hook(bEnable: Boolean); stdcall; export;
begin
if bEnable then
begin
if hhook = 0 then
begin
hhook := SetWindowsHookEx(WH_CALLWNDPROC, TmHookProc, HInstance, 0);
end;
end
else
begin
if hhook <> 0 then
begin
UnhookWindowsHookEx(hhook);
hhook := 0;
end;
end;
end;
exports
Hook;
begin
hhook := 0;
hwndListView := 0;
oldWndProc:=0;
end.
到底哪里错了,一运行,qq就自动关闭??
解决方案 »
- 用Delphi 怎么从server2000导出dbf文件
- 关于界面上转移焦点的问题(运行时使用Table键来转移)
- 想不在当前窗体上输入string,又不想新建窗体、TEdit==,怎么做?
- 如何讓TQRCompositeReport聯合的quickreport強制分頁顯示如下
- 求购售楼软件源代码okareo◎@hotmail.com
- 寻求酒店管理系统的源程序,有费用!!~~
- 关于chart的问题?
- 注册系统热健以及WM_HOTKEY消息处理的一些问题〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉
- 再问一个ServerName的问题
- 何处可以下载MSDN 2001.10和更新版本?如果不知道留下mail,等我知道了通知你!
- 子类化的问题?
- sql server 数据库的问题
这个名称是用spy取到的,我也比对过它的句柄是正确的.