编写了一个鼠标钩子,右键点击的消息能够截获,但是双击消息不能截获,请高手指点。dll程序如下:
library Mouse_HookDLL;uses
  SysUtils,
  Windows,
  Messages,
  Classes;  const WH_MOUSE_LL=14;{$R *.res}var
  NextHook : HHook;
  CallHandle : HWND;
  MessageID : Word;function HookProc(code:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
begin
  Result := 0;
  if code < 0 then
    Result := CallNextHookEx(NextHook,code,wParam,lParam);
  case wParam of
    WM_LBUTTONDOWN:       
    begin
    end;
    WM_LBUTTONUP:
    begin
    end;
    WM_LBUTTONDBLCLK:
    begin
      SendMessage(CallHandle,MessageID,wParam,Integer(@pMouseHookStruct(lParam)^));
    end;
    WM_RBUTTONDOWN:
    begin
    end;
    WM_RBUTTONUP:
    begin
      SendMessage(CallHandle,MessageID,wParam,Integer(@pMouseHookStruct(lParam)^));
    end;
    WM_NCMOUSEMOVE,WM_MOUSEMOVE:
    begin
    end;
  end;
end;//启动钩子
function StartHook(MsgID:Word):Bool;stdcall;
begin
  Result := False;
  if NextHook <> 0 then
    Exit;
  MessageID := MsgID;
  NextHook := SetWindowsHookEx(WH_MOUSE_LL,@HookProc,HInstance,0);
  Result := NextHook <> 0;
end;//脱钩
function StopHook:Bool;stdcall;
begin
  if NextHook <> 0 then
  begin
    UnHookWindowsHookEx(NextHook);
    NextHook := 0;
  end;
  Result := NextHook = 0;
end;//传递调用者句柄
procedure SetCallHandle(sender:HWND);stdcall;
begin
  CallHandle := sender;
  NextHook := 0;
end;exports
  StartHook name 'StartHook',
  StopHook name 'StopHook',
  SetCallHandle name 'SetCallHandle';begin
end.

解决方案 »

  1.   

    调用dll的程序为:
    private
        { Private declarations }
        //重载消息处理
        procedure WndProc(var Message: TMessage);override;const
      WM_TestMsg = WM_User + 100;
    implementation{$R *.dfm}
    function StartHook(MsgID:Word):Bool;stdcall;external 'Mouse_HookDLL.dll';
    function StopHook:Bool;stdcall;external 'Mouse_HookDLL.dll';
    procedure SetCallHandle(sender:HWND);stdcall;external 'Mouse_HookDLL.dll';procedure TForm1.FormShow(Sender: TObject);
    begin
      SetCallHandle(Self.Handle);
      if not StartHook(WM_TestMsg) then   //WM_TestMsg为自定义消息
      begin
        ShowMessage('挂钩失败!');
      end;
    end;
    procedure TForm1.WndProc(var Message: TMessage);
    begin
      //得到符合条件的钩子
      if Message.Msg = WM_TestMsg then
      begin
        memo1.Lines.Add('Get it!');
      end;
      inherited;
    end;
      

  2.   

    点鼠标右键时Memo1中能显示‘Get it!’,而双击时则不行。请高手指教。多谢了。
      

  3.   

    WM_LBUTTONDBLCLK 不会没有用吧,线程却钩子可以 ,不知道什么原因
      

  4.   

    WH_MOUSE_LL不能获得双击消息,你要根据两次单击时间自己判断你还在弄那个东西?
      

  5.   


    呵呵,是啊,没办法啊,任务没有完成呢。
    我试过WH_MOUSE,连右键都捕获不到了。
    根据两次单击时间判断该怎么做呢?
      

  6.   

    判断两次按键时间是不是小于GetDoubleClickTime
      

  7.   

    WH_MOUSE_LL不需要用dll
    你的任务还是获得在资源管理器中打开的文件?
      

  8.   

    不用DLL也可以,用鼠标录像钩子.
      

  9.   

    WH_JOURNALRECORD没有WH_MOUSE_LL好,因为按了CTRL+BREAK就没用了
      

  10.   


    兄弟,恕我愚钝,具体怎么做?如果用dll的方法,如何判断?
      

  11.   

    const WH_MOUSE_LL=14;
      这里=14是怎么来的,是不是应该改成7,delphi 里面定义 WH_MOUSE=7;