Radio Buttons, Lots of them
-
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
-
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
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)
-
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
-
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
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++)[^]
-
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)
-
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
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
-
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
-
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.
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
-
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
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
-
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