Solved

how to get the state of mouse buttons

Posted on 1998-06-12
2
266 Views
Last Modified: 2013-11-20
I need to know the state of the left mouse button when handling a WM_NCMOUSEMOVE (WM_NCMOUSEUP is not sent after a WM_NCMOUSEDOWN, SetCapture() changes nothing)

how to get the state (through API or not...)
0
Comment
Question by:amby
  • 2
2 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 60 total points
ID: 1317908
if (::GetKeyState(VK_LBUTTON) & 0x8000)
    // down
else
    // up

0
 
LVL 23

Expert Comment

by:chensu
ID: 1317909
You may also use GetAsyncKeyState. See the documentation for the difference.

Please note: (I am not sure if it is also true for GetKeyState. You may test it.)

The GetAsyncKeyState function works with mouse buttons. However, it checks on the state of the physical mouse buttons, not on the logical mouse buttons that the physical buttons are mapped to. For example, the call GetAsyncKeyState(VK_LBUTTON) always returns the state of the left physical mouse button, regardless of whether it is mapped to the left or right logical mouse button. You can determine the system's current mapping of physical mouse buttons to logical mouse buttons by calling

GetSystemMetrics(SM_SWAPBUTTON)
 
which returns TRUE if the mouse buttons have been swapped.


0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 106
canBalance challenge 34 65
noX challenge 17 76
unix example issues 18 47
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now