Solved

how to get the state of mouse buttons

Posted on 1998-06-12
2
305 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 47
bigDiff challenge 17 134
centeredAverage challenge 8 185
Change to event 1 127
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.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

756 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