Solved

how to get the state of mouse buttons

Posted on 1998-06-12
2
291 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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.

803 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