Determine whether the mouse moved horizontally (C++)

I can detect a cursor movement over my window by capturing the WM_MOUSEMOVE message. This message contains x and y coordinates but what I need to figure out it whether the user tried to move the mouse horizontally or vertically. I want to ignore the vertical movement if the x-coordinate changed more significantly than y. Do I need to use some other message? Thanks!


David is right that you will likely need to keep track of the state. However, there is a function, GetMouseMovePointsEx that will give you up to 64 previous coordinates of the mouse. You will still have to have a map (or some other data structure) for storing the coordinates yourself, but that function should do a lot of the legwork for you. Then again, I'm not sure how that method will compare to a more manual method as far as deciding where the mouse started so you know what to compare to. *(see edit below)

Once you have the previous coordinates, you can compare the starting position with the latest position. If the difference is greater than some arbitrary amount (that you decide on) then execute your code.

*EDIT: Just read this in the GetMouseMovePointsEx documentation I linked above

The GetMouseMovePointsEx function searches for the point in the mouse coordinates history. If the function finds the point, it returns the last nBufPoints prior to and including the supplied point.

If your application supplies a time stamp, the GetMouseMovePointsEx function will use it to differentiate between two equal points that were recorded at different times.

An application should call this function using the mouse coordinates received from the WM_MOUSEMOVE message and convert them to screen coordinates.

Need Your Help

How do I 'properly' add HTML to my current email output?

php email html-email

Below is the code for an email that my booking script outputs when somebody cancels their booking. I was wondering what the proper way to add HTML around the body of the email would be in this case...

Is it possible automatically instantiation of a nested Property with Commons Bean Utils?

java reflection apache-commons-beanutils

I'm using PropertyUtils.setProperty(object, name, value) method of Apache Commons Bean Utils: