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. Get Mouse Click position

Get Mouse Click position

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphics
4 Posts 3 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.
  • L Offline
    L Offline
    Like2Byte
    wrote on last edited by
    #1

    Hello, How do I grab the info where the mouse is so I can determine the position of the mouse when clicked over a certain region of the screen (say, over a certain part of a bitmap)? I'm creating a dialog based app. thanks!

    M 1 Reply Last reply
    0
    • L Like2Byte

      Hello, How do I grab the info where the mouse is so I can determine the position of the mouse when clicked over a certain region of the screen (say, over a certain part of a bitmap)? I'm creating a dialog based app. thanks!

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      The button down/up messages have the coordinates encoded in the LPARAM. There's also GetCursorPos(). Mark

      L 1 Reply Last reply
      0
      • M Mark Salsbery

        The button down/up messages have the coordinates encoded in the LPARAM. There's also GetCursorPos(). Mark

        L Offline
        L Offline
        Like2Byte
        wrote on last edited by
        #3

        Awesome! Thanks!

        J 1 Reply Last reply
        0
        • L Like2Byte

          Awesome! Thanks!

          J Offline
          J Offline
          James R Twine
          wrote on last edited by
          #4

          Note that there is an important difference between the two ways Mark gave you to get the mouse position. The position associated with the window message may be different than the one you get from GetCursorPos() -- the former is the one at the time the message was sent, the latter is the mouse's position at the time of the call.  If your application is very busy, the two values can be very different. You likely want the position associated with the message:

          GetCurrentMessage() -> pt

          Peace!

          -=- James
          Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
          Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
          See DeleteFXPFiles

          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