user1930581
user1930581

Reputation: 1565

MFC Mouse motion OnMouseMove event nFlags value if no buttons clicked?

I'm working on a project translating old Windows 95 MFC code to C++11. I was wondering, if no mouse buttons are clicked during a move, what is the value of the UINT nFlags passed into the OnMouseMove() function?

I'm not very familiar with MFC and I don't have access to a Windows machine to do any tests myself, so my understanding about this functions behavior may be incorrect. I know that if it's left clicked, middle or right there are special system values that the OnMouseMove function will receive in the nFlags (like MK_LBUTTON, which is 0x0001). I was wondering what the value for nFlags will be if nothing in particular has been clicked and the mouse has move, is it just 0x0000? Thank you very much, any help with this matter is greatly appreciated!

Upvotes: 1

Views: 3407

Answers (1)

Mark Stevens
Mark Stevens

Reputation: 2366

Yes, it's 0.

But I think it would be safest to test for the documented possible values so if its usage is changed in the future, the "0 assuming" code doesn't break. According to MSDN for VS2012, these are the possible values:

MK_CONTROL   Set if the CTRL key is down.
MK_LBUTTON   Set if the left mouse button is down.
MK_MBUTTON   Set if the middle mouse button is down.
MK_RBUTTON   Set if the right mouse button is down.
MK_SHIFT     Set if the SHIFT key is down.

where they are currently defined (in Winuser.h) as:

#define MK_LBUTTON          0x0001
#define MK_RBUTTON          0x0002
#define MK_SHIFT            0x0004
#define MK_CONTROL          0x0008
#define MK_MBUTTON          0x0010

Upvotes: 3

Related Questions