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. CDialog and Mouse clicks

CDialog and Mouse clicks

Scheduled Pinned Locked Moved C / C++ / MFC
questionannouncement
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.
  • M Offline
    M Offline
    mcsherry
    wrote on last edited by
    #1

    What is the best way to detect if a user presses the L button down and releases it within a specified region on a dialog? The way I'm considering doing it is to use the OnLButtonDown and OnLButtonUp methods and set a bool flag when the user presses down whilst within this region and when they release the mouse to check this flag and then check if they are still in the region. Is this the best/recommended way of doing it or is there better more effient ways? TIA,

    N J 2 Replies Last reply
    0
    • M mcsherry

      What is the best way to detect if a user presses the L button down and releases it within a specified region on a dialog? The way I'm considering doing it is to use the OnLButtonDown and OnLButtonUp methods and set a bool flag when the user presses down whilst within this region and when they release the mouse to check this flag and then check if they are still in the region. Is this the best/recommended way of doing it or is there better more effient ways? TIA,

      N Offline
      N Offline
      Nishad S
      wrote on last edited by
      #2

      AFAIK, this is the one... :) But you have to use the SetCapture also.

      - NS -

      M 1 Reply Last reply
      0
      • M mcsherry

        What is the best way to detect if a user presses the L button down and releases it within a specified region on a dialog? The way I'm considering doing it is to use the OnLButtonDown and OnLButtonUp methods and set a bool flag when the user presses down whilst within this region and when they release the mouse to check this flag and then check if they are still in the region. Is this the best/recommended way of doing it or is there better more effient ways? TIA,

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

        Detect a LButtonDown over the region, capture the mouse when this happens, and then wait for the LButtonUp message.  If the LBU is over the region, react.    Watch out for things like (De)activate and/or kill focus messages - if the user switches apps while holding down the mouse button, you will need to release the capture.    The reason you do not want to just react to LBU is that the user could click and hold the mouse button down, and then drag it over to your app and release.  This happens a lot by accident and you would not want to react to that accident.  Try that with a standard button control and you will see what I mean.    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!
        Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
        See DeleteFXPFiles

        1 Reply Last reply
        0
        • N Nishad S

          AFAIK, this is the one... :) But you have to use the SetCapture also.

          - NS -

          M Offline
          M Offline
          mcsherry
          wrote on last edited by
          #4

          cheers, I implemented it as I described but also used SetCapture and ReleaseCapture and it worked a treat :D

          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