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 Query.

Radio Button Query.

Scheduled Pinned Locked Moved C / C++ / MFC
c++databasequestion
5 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.
  • C Offline
    C Offline
    cagespear
    wrote on last edited by
    #1

    I have an MFC Dialog which houses 3 radio buttons. I want to take some action only when user selects radio button which is not selected already so that I don't perform the same set of actions if a user RE-Selects a radio button. Can someone advise me what's the best way to achieve this ? Thanks Cage

    R 1 Reply Last reply
    0
    • C cagespear

      I have an MFC Dialog which houses 3 radio buttons. I want to take some action only when user selects radio button which is not selected already so that I don't perform the same set of actions if a user RE-Selects a radio button. Can someone advise me what's the best way to achieve this ? Thanks Cage

      R Offline
      R Offline
      rp_suman
      wrote on last edited by
      #2

      Hi, You mean when clicking the same radio button again and again or when selecting a button and change to other again come back to previous button? In second case, you can set a static variable like static bool bAlreadySelected = true when the button clicked already it will be true. Otherwise perform the set of options. Set the above variable to false at startup of dialog. This is one way. There may be some other way too. Thanks, Suman

      -- "Programming is an art that fights back!"

      modified on Friday, April 4, 2008 1:22 AM

      C 1 Reply Last reply
      0
      • R rp_suman

        Hi, You mean when clicking the same radio button again and again or when selecting a button and change to other again come back to previous button? In second case, you can set a static variable like static bool bAlreadySelected = true when the button clicked already it will be true. Otherwise perform the set of options. Set the above variable to false at startup of dialog. This is one way. There may be some other way too. Thanks, Suman

        -- "Programming is an art that fights back!"

        modified on Friday, April 4, 2008 1:22 AM

        C Offline
        C Offline
        cagespear
        wrote on last edited by
        #3

        No Suman, that doesnt solve my problem. I want to take a certain action everytime the control is transferred from the other radio button, not just for the first time. Let me be more clear. Example - Three radio buttons be A, B and C. I want to perform certain operations everytime user has selected A or B and then he clicks C, but I don't want to take any action if user re-selects C.

        C 1 Reply Last reply
        0
        • C cagespear

          No Suman, that doesnt solve my problem. I want to take a certain action everytime the control is transferred from the other radio button, not just for the first time. Let me be more clear. Example - Three radio buttons be A, B and C. I want to perform certain operations everytime user has selected A or B and then he clicks C, but I don't want to take any action if user re-selects C.

          C Offline
          C Offline
          Cedric Moonen
          wrote on last edited by
          #4

          That's not very complicated: in your class declare an integer variable (e.g. m_currentSelected). On each of your radio button handler functions, assign a value to this variable (e.g. 1 for the first radio button, 2 for the second, ...). It is easier with code:

          void CMyClass::OnRadio1Clicked()
          {
          if(m_currentSelected==1)
          return;

          // Do stuff....

          m_currentSelected = 1;
          }

          Cédric Moonen Software developer
          Charting control [v1.3]

          C 1 Reply Last reply
          0
          • C Cedric Moonen

            That's not very complicated: in your class declare an integer variable (e.g. m_currentSelected). On each of your radio button handler functions, assign a value to this variable (e.g. 1 for the first radio button, 2 for the second, ...). It is easier with code:

            void CMyClass::OnRadio1Clicked()
            {
            if(m_currentSelected==1)
            return;

            // Do stuff....

            m_currentSelected = 1;
            }

            Cédric Moonen Software developer
            Charting control [v1.3]

            C Offline
            C Offline
            cagespear
            wrote on last edited by
            #5

            Thanks Cedric. This helps, I was thinking on these lines but felt that may be if through MFC we can achieve this ?

            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