鼠标钩子消息问题如何监视 鼠标 双击的时候 就执行特定代码 求解 

解决方案 »

  1.   

    以下是我写的传递数据的部分代码,有些变量可以不必使用
    unit DLL;interfaceuses
      Windows,Messages;function StartHook:Boolean;stdcall;
    function EndHook:Boolean;stdcall;
    function MouseProc(nCode:Integer;wParam:WPARAM;lParam:LPARAM):LongInt;stdcall;const
       WM_MYMESSAGE=WM_USER+1024;//type
    //  PShareMem=^TShareMem;
    //  TShareMem=record
    //     DATA:TMouseHookStruct;
    //end;var
      hMap:THandle;
      pVoid:Pointer;
      hMouseHook:HHOOK;
      DATA:TMouseHookStruct;
      IsHooked:Boolean;
    implementation
    //------------------------------------------------------------------------------function MouseProc(nCode:Integer;wParam:WPARAM;lParam:LPARAM):LongInt;stdcall;
    begin
      Result:=0;  if nCode < 0 then
        Result:=CallNextHookEx(hMouseHook,nCode,wParam,lParam);  if wParam=WM_LBUTTONDBLCLK then
      begin
      //这里写下你自己的代码
      end;
    end;
    //------------------------------------------------------------------------------
    function StartHook:Boolean;stdcall;
    begin
      if IsHooked=False then
      begin
        hMouseHook:=SetWindowsHookEx(WH_MOUSE,@MouseProc,HInstance,0);
        if hMouseHook<> 0 then
        begin
          IsHooked:=True;
          Result:=True;
        end
        else
          Result:=False;
      end;
    end;