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 Buttons, Lots of them

Radio Buttons, Lots of them

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++visual-studioquestion
10 Posts 5 Posters 2 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
    golfbird
    wrote on last edited by
    #1

    I have a dialog of radio buttons, 100 of them I use this to select type of material product is made from so I can select correct ink for printing. Selections are everything from alumininum, plastics to wood. I would like to select 1 radio button and have it return the int of that selection without having to add an event handler for each and everyone of the radio buttons Is there a routine that can handle any check on any button? If(any button is checked) return(int # of the button) Using visual studio c++ 2008

    Peter Boyko

    L P D 4 Replies Last reply
    0
    • G golfbird

      I have a dialog of radio buttons, 100 of them I use this to select type of material product is made from so I can select correct ink for printing. Selections are everything from alumininum, plastics to wood. I would like to select 1 radio button and have it return the int of that selection without having to add an event handler for each and everyone of the radio buttons Is there a routine that can handle any check on any button? If(any button is checked) return(int # of the button) Using visual studio c++ 2008

      Peter Boyko

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You can hook up the same event for each button. The sender can be identified by the sender parameter of the event. It contains a reference to the button, and thus, its name. --sorry, thought this was the C# forum. Doesn't MFC have something similar?

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

      G 1 Reply Last reply
      0
      • G golfbird

        I have a dialog of radio buttons, 100 of them I use this to select type of material product is made from so I can select correct ink for printing. Selections are everything from alumininum, plastics to wood. I would like to select 1 radio button and have it return the int of that selection without having to add an event handler for each and everyone of the radio buttons Is there a routine that can handle any check on any button? If(any button is checked) return(int # of the button) Using visual studio c++ 2008

        Peter Boyko

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        golfbird wrote:

        I have a dialog of radio buttons, 100 of them

        That is a really bad idea. Use a ListBox, or preferably more than 1 to allow simple selection of items.

        G 1 Reply Last reply
        0
        • G golfbird

          I have a dialog of radio buttons, 100 of them I use this to select type of material product is made from so I can select correct ink for printing. Selections are everything from alumininum, plastics to wood. I would like to select 1 radio button and have it return the int of that selection without having to add an event handler for each and everyone of the radio buttons Is there a routine that can handle any check on any button? If(any button is checked) return(int # of the button) Using visual studio c++ 2008

          Peter Boyko

          P Offline
          P Offline
          Peter Leow
          wrote on last edited by
          #4

          Richard is right. Having 100 radio buttons, it is unusable. Can you categorize them and may be make use of dropdown boxes. Check this out Radio Buttons in MFC (Visual Studio 2008 / C++)[^]

          1 Reply Last reply
          0
          • L Lost User

            You can hook up the same event for each button. The sender can be identified by the sender parameter of the event. It contains a reference to the button, and thus, its name. --sorry, thought this was the C# forum. Doesn't MFC have something similar?

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

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

            if it does, I'm not able to find it. Could be I'm looking at the wrong pages.

            Peter Boyko

            1 Reply Last reply
            0
            • G golfbird

              I have a dialog of radio buttons, 100 of them I use this to select type of material product is made from so I can select correct ink for printing. Selections are everything from alumininum, plastics to wood. I would like to select 1 radio button and have it return the int of that selection without having to add an event handler for each and everyone of the radio buttons Is there a routine that can handle any check on any button? If(any button is checked) return(int # of the button) Using visual studio c++ 2008

              Peter Boyko

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

              golfbird wrote:

              I have a dialog of radio buttons, 100 of them

              Very unfriendly UI. The second parameter to the ON_BN_CLICKED() macro can point to the same handler function.

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

              G 1 Reply Last reply
              0
              • D David Crow

                golfbird wrote:

                I have a dialog of radio buttons, 100 of them

                Very unfriendly UI. The second parameter to the ON_BN_CLICKED() macro can point to the same handler function.

                "One man's wage rise is another man's price increase." - Harold Wilson

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                G Offline
                G Offline
                golfbird
                wrote on last edited by
                #7

                Thanks.. I have to believe the objective I'm trying to reach is beyond me. Thank You all again.

                Peter Boyko

                1 Reply Last reply
                0
                • L Lost User

                  golfbird wrote:

                  I have a dialog of radio buttons, 100 of them

                  That is a really bad idea. Use a ListBox, or preferably more than 1 to allow simple selection of items.

                  G Offline
                  G Offline
                  golfbird
                  wrote on last edited by
                  #8

                  thanks you have busted my bubble. To me, it seemed easier to look at a dialog page with radio buttons rather than search a listing especially for my printers who may not have to learn how to use drop down list boxes Seems to me that the program knows when a radio button is selected and then marks is as such and turns off all others in the group.. I was hoping I could intercept the routine and just add my own function to it.

                  Peter Boyko

                  J 1 Reply Last reply
                  0
                  • G golfbird

                    thanks you have busted my bubble. To me, it seemed easier to look at a dialog page with radio buttons rather than search a listing especially for my printers who may not have to learn how to use drop down list boxes Seems to me that the program knows when a radio button is selected and then marks is as such and turns off all others in the group.. I was hoping I could intercept the routine and just add my own function to it.

                    Peter Boyko

                    J Offline
                    J Offline
                    jeron1
                    wrote on last edited by
                    #9

                    golfbird wrote:

                    I was hoping I could intercept the routine and justadd my own function to it.

                    You can, see Davids reply. You'll need an ON_BN_CLICKED() entry for every radio button, but the function that gets called can be the same. Though for a 100 buttons I imagine it gets unwieldy.

                    BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
                    //{{AFX_MSG_MAP(CMyDialog)
                    ON_BN_CLICKED(IDC_RADIO_1, OnRadioClick)
                    ON_BN_CLICKED(IDC_RADIO_2, OnRadioClick)
                    ON_BN_CLICKED(IDC_RADIO_3, OnRadioClick)
                    //}}AFX_MSG_MAP
                    END_MESSAGE_MAP()

                    "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

                    G 1 Reply Last reply
                    0
                    • J jeron1

                      golfbird wrote:

                      I was hoping I could intercept the routine and justadd my own function to it.

                      You can, see Davids reply. You'll need an ON_BN_CLICKED() entry for every radio button, but the function that gets called can be the same. Though for a 100 buttons I imagine it gets unwieldy.

                      BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
                      //{{AFX_MSG_MAP(CMyDialog)
                      ON_BN_CLICKED(IDC_RADIO_1, OnRadioClick)
                      ON_BN_CLICKED(IDC_RADIO_2, OnRadioClick)
                      ON_BN_CLICKED(IDC_RADIO_3, OnRadioClick)
                      //}}AFX_MSG_MAP
                      END_MESSAGE_MAP()

                      "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

                      G Offline
                      G Offline
                      golfbird
                      wrote on last edited by
                      #10

                      This looks like what I was looking for. Appreciate it, will give it a test thank you

                      Peter Boyko

                      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