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. How to access Radio Button with just ID

How to access Radio Button with just ID

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

    I have a number of radio buttons. I want to enter their ID's in a std::map for later use. But I can't figure out how to set the correct button from it's ID. IOW, given a group consisting of 2 radio buttons and their ID's (IDC_R1, IDC_R2), does anyone know how to set which one is picked? Jack

    A J 2 Replies Last reply
    0
    • J Jack_pt

      I have a number of radio buttons. I want to enter their ID's in a std::map for later use. But I can't figure out how to set the correct button from it's ID. IOW, given a group consisting of 2 radio buttons and their ID's (IDC_R1, IDC_R2), does anyone know how to set which one is picked? Jack

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

      CButton * butt = (CButton *) GetDlgItem(IDC_R1); CButton * head = (CButton *) GetDlgItem(IDC_R2); Regards,

      J 1 Reply Last reply
      0
      • J Jack_pt

        I have a number of radio buttons. I want to enter their ID's in a std::map for later use. But I can't figure out how to set the correct button from it's ID. IOW, given a group consisting of 2 radio buttons and their ID's (IDC_R1, IDC_R2), does anyone know how to set which one is picked? Jack

        J Offline
        J Offline
        Jack Puppy
        wrote on last edited by
        #3

        I used to use the pointer method, and then one day I stumbled upon this function: UINT IsDlgButtonChecked( int nIDButton ) const; So, if you want to determine if the IDC_R1 button is checked, simply: if (IsDlgButtonChecked(IDC_R1) != 0) AfxMessageBox("Checked");

        :cool: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!

        J 1 Reply Last reply
        0
        • A Anonymous

          CButton * butt = (CButton *) GetDlgItem(IDC_R1); CButton * head = (CButton *) GetDlgItem(IDC_R2); Regards,

          J Offline
          J Offline
          Jack_pt
          wrote on last edited by
          #4

          Thanks. That's what I was using but when I was doing the SetCheck, I forgot to uncheck the other controls so the program was aborting due to too many controls being enabled. I thought I was calling the control wrong. Jack

          1 Reply Last reply
          0
          • J Jack Puppy

            I used to use the pointer method, and then one day I stumbled upon this function: UINT IsDlgButtonChecked( int nIDButton ) const; So, if you want to determine if the IDC_R1 button is checked, simply: if (IsDlgButtonChecked(IDC_R1) != 0) AfxMessageBox("Checked");

            :cool: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!

            J Offline
            J Offline
            Jack_pt
            wrote on last edited by
            #5

            Thanks, I appreciate you mentioning that. But the problem I was having had to do with setting it, not checking if it was set. Turns out I was setting it correctly but I was also not un-setting the other radio buttons. It's working fine now. Jack

            B 1 Reply Last reply
            0
            • J Jack_pt

              Thanks, I appreciate you mentioning that. But the problem I was having had to do with setting it, not checking if it was set. Turns out I was setting it correctly but I was also not un-setting the other radio buttons. It's working fine now. Jack

              B Offline
              B Offline
              Bo Hunter
              wrote on last edited by
              #6

              Check out CheckRadioButton api on msdn. Thank You Bo Hunter

              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