Created
October 26, 2016 11:32
-
-
Save Virenbar/b03e818e2ebc58a85e42940dbc7e33f1 to your computer and use it in GitHub Desktop.
Delphi Mouse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uses | |
... | |
, Windows | |
, ... | |
; | |
type | |
TMouseBtnType = (mbLeft, mbMiddle, mbRight); | |
const | |
MOUSE_BTN_VKEYS: Array [TMouseBtnType] of Integer = (VK_LBUTTON, VK_MBUTTON, VK_RBUTTON); | |
(* This function returns true when the specified mouse button is pressed *) | |
function IsMouseBtnDown(const AMouseBtn: TMouseBtnType): Boolean; | |
begin | |
Result := GetAsyncKeyState(MOUSE_BTN_VKEYS[AMouseBtn]) | |
AND $8000 <> 0; | |
end; | |
(* This function returns true when any of the mouse button is pressed *) | |
function IsMouseBtnDown: Boolean; | |
begin | |
Result := (GetAsyncKeyState(VK_LBUTTON) | |
OR GetAsyncKeyState(VK_MBUTTON) | |
OR GetAsyncKeyState(VK_RBUTTON) | |
) | |
AND $8000 <> 0; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://forum.codecall.net/topic/74502-anytime-detect-if-mouse-button-is-down/