如果用户同时按下了鼠标左键与滚轮键则不执行任何操作,用什么办法搞定,谢了

解决方案 »

  1.   

    procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      if GetAsyncKeyState(VK_LButton)<>0 and GetAsyncKeyState(VK_MButton)<>0 then
      begin
        exit;
      end;
    end;
      

  2.   

    楼上的,你的代码不能用,不正确,你把哪个exit换成showMessage('aaa');然后运行程序试试,我同时按下了鼠标左键与滚轮根本不会弹出对话框
      

  3.   

    procedure TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState;
      WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
    begin
      if GetAsyncKeyState(VK_LButton)<>0 then
      begin
        Label1.Tag := Label1.Tag + 1;
        Label1.Caption := IntToStr(Label1.Tag);
      end;
    end;
      

  4.   

    不如用全局变量记下刚才按了什么键,然后在FormMouseDown里面把现在的键值和先前的键值一起判断,看是不是同时按下了左键和中键。FormMouseUp过程也要处理一下。
      

  5.   

    我试一下,估计不行,因为我滚动鼠标的滚轮时在OnMouseDown里并不会触发事件
      

  6.   

    滚轮滚动会触发FormMouseWheel
    ssq237712(流亡帅哥)的回复里面不是有么?
      

  7.   

    procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    var TheMessage:TMSG;
    begin
      WaitMessage();
      PeekMessage(TheMessage,Handle,0,0,PM_REMOVE);
      if TheMessage.message=WM_MBUTTONDOWN then //等待中键按下的消息
       ShowMessage('同时按下');
    end;