Sign in to follow this  
McCoder

Win32 and Mouse Movement

Recommended Posts

How do I capture mouse movement using the Win32 API? I want to capture mouse movement but only when the middle mouse button is down, so I could rotate an OpenGL Scene. The trouble is this that this code (http://pastebin.com/m4f2349a5) does not work at all and gives me an error: error C2196: case value '16' already used Any idea of what I am doing wrong?

Share this post


Link to post
Share on other sites
First, it's easier to use [source] tags to paste code on the forums.
Second, that code doesn't make sense. You probably want:

case WM_MOUSEMOVE:
{
if(wParam & MK_MBUTTON)
{
WriteFile(handle, msg1, strlen(msg1), &dwBytesWritten, NULL);
}
}

Assuming you want to write the data to the file when the mouse moves and the middle mouse button is down.

Share this post


Link to post
Share on other sites
&& is the and operator.
& is the bitwise and operator.
& is used to check bits of a word and |(bitwise or) is used to set them etc.
I dunno what EvilSteve tried there though :P

[Edited by - Black Knight on September 16, 2008 6:14:28 AM]

Share this post


Link to post
Share on other sites
The wParam member contains information about more than just the middle mouse button, but setting different bits of the number. Using & you're checking if the bit representing the middle mouse button is set. If you use ==, then you'll only write to the file if the middle mouse button alone is down, not if the middle mouse button plus control, alt, any other mouse buttons, etc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this