Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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
Sign In or Register to comment.