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. radio button states

radio button states

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

    i have 2 radio buttons grouped together, variable name is m_button, when i checked the .cpp file, m_button =-1 (initialized). How do i detect which button has been checked? if i use: if(m_button!=-1) then this means can be button a or button b but i want to detect specifically either one. anyone can clarify? thanx

    L R P A 4 Replies Last reply
    0
    • C coda_x

      i have 2 radio buttons grouped together, variable name is m_button, when i checked the .cpp file, m_button =-1 (initialized). How do i detect which button has been checked? if i use: if(m_button!=-1) then this means can be button a or button b but i want to detect specifically either one. anyone can clarify? thanx

      L Offline
      L Offline
      l a u r e n
      wrote on last edited by
      #2

      radio buttons are weird they actually get put into an array in effect so the value u get back is the zero-based index of the radio button within the group (as far as i recall) :)


      "there is no spoon"
      biz stuff   about me

      1 Reply Last reply
      0
      • C coda_x

        i have 2 radio buttons grouped together, variable name is m_button, when i checked the .cpp file, m_button =-1 (initialized). How do i detect which button has been checked? if i use: if(m_button!=-1) then this means can be button a or button b but i want to detect specifically either one. anyone can clarify? thanx

        R Offline
        R Offline
        Ravi Bhavnani
        wrote on last edited by
        #3

        Use separate CButton members for each radio button. Then test this condition:

        m_checkButton_1.GetCheck() == BST_CHECKED

        to see if it's checked. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

        S 1 Reply Last reply
        0
        • R Ravi Bhavnani

          Use separate CButton members for each radio button. Then test this condition:

          m_checkButton_1.GetCheck() == BST_CHECKED

          to see if it's checked. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

          S Offline
          S Offline
          Selvam R
          wrote on last edited by
          #4

          Hi, I think radio buttons with in group box ( privious one) is better then separate CButton members for each radio button. Correct!!? With Regards, R.Selvam

          R 1 Reply Last reply
          0
          • C coda_x

            i have 2 radio buttons grouped together, variable name is m_button, when i checked the .cpp file, m_button =-1 (initialized). How do i detect which button has been checked? if i use: if(m_button!=-1) then this means can be button a or button b but i want to detect specifically either one. anyone can clarify? thanx

            P Offline
            P Offline
            Prakash Nadar
            wrote on last edited by
            #5

            There are good tutorials on radio button on CP you can check them out. My God is more powerfull Than Your God. (the line that divides the world)

            1 Reply Last reply
            0
            • S Selvam R

              Hi, I think radio buttons with in group box ( privious one) is better then separate CButton members for each radio button. Correct!!? With Regards, R.Selvam

              R Offline
              R Offline
              Ravi Bhavnani
              wrote on last edited by
              #6

              I prefer to use individual (CWnd derived) members for each controls. That gives me complete control over my GUI and would also address your issue. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

              1 Reply Last reply
              0
              • C coda_x

                i have 2 radio buttons grouped together, variable name is m_button, when i checked the .cpp file, m_button =-1 (initialized). How do i detect which button has been checked? if i use: if(m_button!=-1) then this means can be button a or button b but i want to detect specifically either one. anyone can clarify? thanx

                A Offline
                A Offline
                asierra
                wrote on last edited by
                #7

                m_button =-1 "None Checked" m_button = 0 "button a Checked" m_button = 1 "button b Checked"

                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