Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Mouse Click Event Validation Issue

Mouse Click Event Validation Issue

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TClarke
    wrote on last edited by
    #1

    Hi all, I have a strange issue where an app which I'm getting events from is sometimes producing right click events when a left mouse click is actually what happened. Is there a windows buffer I can read which will allow me to validate the event without having to record all the mouse events myself. Thanks

    Cheers Tom Philosophy: The art of never getting beyond the concept of life. Religion: Morality taking credit for the work of luck.

    T 1 Reply Last reply
    0
    • T TClarke

      Hi all, I have a strange issue where an app which I'm getting events from is sometimes producing right click events when a left mouse click is actually what happened. Is there a windows buffer I can read which will allow me to validate the event without having to record all the mouse events myself. Thanks

      Cheers Tom Philosophy: The art of never getting beyond the concept of life. Religion: Morality taking credit for the work of luck.

      T Offline
      T Offline
      TClarke
      wrote on last edited by
      #2

      I'm now using the lines:

      SHORT rbstate = GetAsyncKeyState(VK_RBUTTON);
      if (!rbstate) {
      return;
      }

      It just makes sure the right mouse button was the one used.

      Cheers Tom Philosophy: The art of never getting beyond the concept of life. Religion: Morality taking credit for the work of luck.

      S 1 Reply Last reply
      0
      • T TClarke

        I'm now using the lines:

        SHORT rbstate = GetAsyncKeyState(VK_RBUTTON);
        if (!rbstate) {
        return;
        }

        It just makes sure the right mouse button was the one used.

        Cheers Tom Philosophy: The art of never getting beyond the concept of life. Religion: Morality taking credit for the work of luck.

        S Offline
        S Offline
        sashoalm
        wrote on last edited by
        #3

        Just want to add a little note. GetAsyncKeyState will return the state at the moment you're calling it, which will always be slightly later than the moment the message was generated. That shouldn't be a problem normally, but you might want to keep that in mind.

        There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

        T 1 Reply Last reply
        0
        • S sashoalm

          Just want to add a little note. GetAsyncKeyState will return the state at the moment you're calling it, which will always be slightly later than the moment the message was generated. That shouldn't be a problem normally, but you might want to keep that in mind.

          There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

          T Offline
          T Offline
          TClarke
          wrote on last edited by
          #4

          Thanks for the response. GetAsyncKeyState also returns a value > 0 if the key was pressed since the last call to it as well as if the event is currently active. If I'm checking for the right mouse key and someomeone enters the sequence: right key, left key, right key and I make a call each time, I should at least get 0,0 1. To counteract the first false negative I ignore the first call's result assuming that the first right click event is always correct as in this case the first event is what sets off the problem. I'm assuming this is what is going on as it now works. It's not the way I would have chosen. I'll have to keep an eye on it. Again, thanks for the comment,

          Cheers Tom Philosophy: The art of never getting beyond the concept of life. Religion: Morality taking credit for the work of luck.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups