Message handling - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Message handling

RX7RX7 Posts: 9Member
Is it possible to handle two messages, say [b]WM_LBUTTONDOWN[/b] and [b]WM_MOUSEMOVE[/b], to do something when you hold the left mousebutton down and move the mouse?

Comments

  • AlienripperAlienripper Posts: 133Member
    : Is it possible to handle two messages, say [b]WM_LBUTTONDOWN[/b] and [b]WM_MOUSEMOVE[/b], to do something when you hold the left mousebutton down and move the mouse?
    :

    Sure it is..
    Just set a flag in WM_LBUTTONDOWN handler and do stuff in WM_MOUSEMOVE. Clear the flag in WM_LBUTTONUP.
    Notice that if you hold left button and move the mouse out of the window and release left button, the flag won't be cleared..

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    When you receive WM_LBUTTONDOWN - call SetCapture() and on WM_LBUTTONUP call ReleaseCapture(). This way you get all mouse input relative to the HWND where you started...

    It is a good idea to go with the flag - not with anything else. When you open any dialog and double click on some control (to close the dialog) - you get the last WM_LBUTTONUP without WM_LBUTTONDOWN and it messes up the algorithm...


  • RX7RX7 Posts: 9Member
    Thanks guys!


Sign In or Register to comment.