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. efficient 'push&hold' button ?

efficient 'push&hold' button ?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionannouncement
6 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.
  • G Offline
    G Offline
    ganjabro
    wrote on last edited by
    #1

    i'm trying to implement a button that functions for example the way that the seek or pitchbend controls function on a cd player. that is, you press/'push' it and 'work starts getting done' and 'stops getting done' when/after you release the button. the only way that i know and that works is to check mouse coordinates upon WM_LBUTTONDOWN/UP (since WM_COMMAND gets sent only after you press and depress a button) and compare them with the button position/recantgle and then take appropriate action... but that seems too complicated (calculating, storing & comparing coordinates), is there a simpler way ? thnx :)

    D 1 Reply Last reply
    0
    • G ganjabro

      i'm trying to implement a button that functions for example the way that the seek or pitchbend controls function on a cd player. that is, you press/'push' it and 'work starts getting done' and 'stops getting done' when/after you release the button. the only way that i know and that works is to check mouse coordinates upon WM_LBUTTONDOWN/UP (since WM_COMMAND gets sent only after you press and depress a button) and compare them with the button position/recantgle and then take appropriate action... but that seems too complicated (calculating, storing & comparing coordinates), is there a simpler way ? thnx :)

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      There are lots of button examples here.


      "Take only what you need and leave the land as you found it." - Native American Proverb

      A 1 Reply Last reply
      0
      • D David Crow

        There are lots of button examples here.


        "Take only what you need and leave the land as you found it." - Native American Proverb

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        DavidCrow wrote:

        There are lots of button examples here.

        i know, but there are only two examples on this/similar topic. http://www.codeproject.com/cpp/mouserepeat.asp[^] and http://codeproject.com/buttonctrl/repeatbutton.asp[^]. actualy that is only one example since the latter uses the first, and they both use the 'check if in client rectangle on lmbutton down' method and mfc... i'm looking for a perhaps simpler/more efficient method (and with using just win32) ...

        D 1 Reply Last reply
        0
        • A Anonymous

          DavidCrow wrote:

          There are lots of button examples here.

          i know, but there are only two examples on this/similar topic. http://www.codeproject.com/cpp/mouserepeat.asp[^] and http://codeproject.com/buttonctrl/repeatbutton.asp[^]. actualy that is only one example since the latter uses the first, and they both use the 'check if in client rectangle on lmbutton down' method and mfc... i'm looking for a perhaps simpler/more efficient method (and with using just win32) ...

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Anonymous wrote:

          i'm looking for a perhaps simpler/more efficient method (and with using just win32) ...

          While only partially related, have you seen this?


          "Take only what you need and leave the land as you found it." - Native American Proverb

          G 1 Reply Last reply
          0
          • D David Crow

            Anonymous wrote:

            i'm looking for a perhaps simpler/more efficient method (and with using just win32) ...

            While only partially related, have you seen this?


            "Take only what you need and leave the land as you found it." - Native American Proverb

            G Offline
            G Offline
            ganjabro
            wrote on last edited by
            #5

            DavidCrow wrote:

            While only partially related, have you seen this?

            hmm thanks for the link but i can't find the handling of WM_LMBUTTONDOWN (and checking if it's for the desired button) in the shown code of that example... am i blind or is it somehow hidden/already implemented by mfc ? i found a different approach, explained here http://www.pluralsight.com/articlecontent/cpprep0797.htm[^]. it seems simpler and more logical but to implement it for this purpose the button control, that is it's window, should have it's own window procedure which i could then override to handle WM_LMBUTTONDOWN/UP messages... so my question is do even the buttons have a window procedure ? although when i think about it this approach also isn't as straitforward as it looks, at least not for what i need to use it. in the new wnd procedure i would then have to call GetParent() and then send a message to the parent dialogbox which would then again have to be processed by the dialogbox procedure ... :) in your opinion, which method is more efficient then ? :)

            G 1 Reply Last reply
            0
            • G ganjabro

              DavidCrow wrote:

              While only partially related, have you seen this?

              hmm thanks for the link but i can't find the handling of WM_LMBUTTONDOWN (and checking if it's for the desired button) in the shown code of that example... am i blind or is it somehow hidden/already implemented by mfc ? i found a different approach, explained here http://www.pluralsight.com/articlecontent/cpprep0797.htm[^]. it seems simpler and more logical but to implement it for this purpose the button control, that is it's window, should have it's own window procedure which i could then override to handle WM_LMBUTTONDOWN/UP messages... so my question is do even the buttons have a window procedure ? although when i think about it this approach also isn't as straitforward as it looks, at least not for what i need to use it. in the new wnd procedure i would then have to call GetParent() and then send a message to the parent dialogbox which would then again have to be processed by the dialogbox procedure ... :) in your opinion, which method is more efficient then ? :)

              G Offline
              G Offline
              ganjabro
              wrote on last edited by
              #6

              domagoj saric wrote:

              so my question is do even the buttons have a window procedure ?

              :doh: the psdk says it does :-O :)

              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