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. CButton GetState , how to read the press and hold state of a button?

CButton GetState , how to read the press and hold state of a button?

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

    Hello, in my aplication using VC** 6.0 , there are two buttons ( + and -) they controls the value of 16 different edit boxes. It's working, but now i want that if you press and hold one these two buttons the value on their respective edit box increases until you release the button. From the help, i read that you can do this using GetState(), with this mask 0x0004, but i can't get it works. here is some code

    void CCalibracionDlg::OnBUTTONmas()
    {
    unsigned int BotonHold=0;
    char incremento;
    BotonHold=0x0004 & m_Button_mas.GetState();
    while (BotonHold != 0)
    {
    incremento=1;
    Decremento_Incremento(incremento);
    BotonHold=0x0004 & m_Button_mas.GetState();
    }
    }

    this is the code for button "+" . I hope i've explained it well.

    H R 2 Replies Last reply
    0
    • T timbk

      Hello, in my aplication using VC** 6.0 , there are two buttons ( + and -) they controls the value of 16 different edit boxes. It's working, but now i want that if you press and hold one these two buttons the value on their respective edit box increases until you release the button. From the help, i read that you can do this using GetState(), with this mask 0x0004, but i can't get it works. here is some code

      void CCalibracionDlg::OnBUTTONmas()
      {
      unsigned int BotonHold=0;
      char incremento;
      BotonHold=0x0004 & m_Button_mas.GetState();
      while (BotonHold != 0)
      {
      incremento=1;
      Decremento_Incremento(incremento);
      BotonHold=0x0004 & m_Button_mas.GetState();
      }
      }

      this is the code for button "+" . I hope i've explained it well.

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      Why you dont use of CSpinButtonCtrl Class?

      Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

      T 1 Reply Last reply
      0
      • T timbk

        Hello, in my aplication using VC** 6.0 , there are two buttons ( + and -) they controls the value of 16 different edit boxes. It's working, but now i want that if you press and hold one these two buttons the value on their respective edit box increases until you release the button. From the help, i read that you can do this using GetState(), with this mask 0x0004, but i can't get it works. here is some code

        void CCalibracionDlg::OnBUTTONmas()
        {
        unsigned int BotonHold=0;
        char incremento;
        BotonHold=0x0004 & m_Button_mas.GetState();
        while (BotonHold != 0)
        {
        incremento=1;
        Decremento_Incremento(incremento);
        BotonHold=0x0004 & m_Button_mas.GetState();
        }
        }

        this is the code for button "+" . I hope i've explained it well.

        R Offline
        R Offline
        Rozis
        wrote on last edited by
        #3

        I'm sorry i'm not in VC but as a C-Programmer (kind of) I would suggest: Create a function/method Scroll() that has 1 argument with value 1 (meaning spin down) and -1 (meaning spin up). Intercept the mousebuttondown-message. When the mouse is down, call Scroll() and set a timer such that when it goes off Scroll() is called again. Intercept the mousebuttonup-message. When the mouse is up set the timer off - that's it. If you also intercept the mousewheel-message you can then reroute those to your Scroll() - The user can use the mousewheel to spin. I'm sorry i don't have the code, or maybe better options, but i hope it helps... Rozis

        1 Reply Last reply
        0
        • H Hamid Taebi

          Why you dont use of CSpinButtonCtrl Class?

          Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

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

          thanks for your answer , but if use CSpinButtonCtrl class , i only be able to control one edit box (his partner control) , and want to control one between 16 edit boxes ( the one who has the focus)with the same pair of bottons + and - . am i right ?

          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