在onMouseDowm事件
var
  KeyBoard:TKeyBoardState;
begin
  GetKeyBoardState(KeyBoard);
  if (KeyBoard[vk_LButton]) and $80 <>0 then
    showMessage('Left Button');
  if (KeyBoard[vk_LButton]) and(KeyBoard[vk_RButton]) and $80 <>0 then
    ShowMessage('Left And Right Button');
end;为什么同时按下左右键却只能显示按下左键时的消息???
还有  $80是什么???

解决方案 »

  1.   

    if ((KeyBoard[vk_LButton]) and $80 <>0) and ((KeyBoard[vk_RButton]) and $80 <>0) then
    ShowMessage('Left And Right Button');
      

  2.   

    $80 是 windows 的 desktop 句柄, 用 GetDeskTopWindow 可以得到 $80
    !
      

  3.   

    ......晕
    $80是16进制的  
     用KeyBoard[vk_LButton]和$80进行与运算~~
     之所以这样做,是由 keyboard[key]对应的每一位代表不同意义决定的,应该有相关资料的
      

  4.   

    BOOL GetKeyboardState(
      PBYTE lpKeyState   // pointer to array to receive status data
    );
     
    lpKeyState 
    Pointer to the 256-byte array that will receive the status data for each virtual key.
    上面是msdn的说明,所以说KeyBoard是一个数组,我估计定义是
    Type
      KeyBoard=array[0..255]of Byte;
    至于$80对应是二进制是1的哪2位我估计是一个是表示按下状态位~