![]() |
|
#1
|
|||
|
|||
radio buttonshello all,
thank you for replying to my previous message luciwicz. i moved away from the mfc part of my project for a while, but now its time to work on it again! i have created some five radio buttons. i read somewhere that there is a way to group them together. is this true? i can only select one out of the five buttons, so maybe this is already done. i was wondering how i can figure out which one is selected? i know that there is a GetCheck() method. But is there a better way to figure out which button has been marked instead of checking each one individually? the following is the code where i declare the buttons, just so you can make sure i'm doing things teh way i'm supposed to! i have, of course, declared them somewhere else (in a header file). CPP / C++ / C Code:
Last edited by LuciWiz : 13-Oct-2004 at 01:16.
Reason: Please insert your c++ code between [c++] [/c++] tags
|
|||
|
#2
|
||||
|
||||
|
When you create the buttons via the Resource Editor, if you access the properties of one of the created buttons, you will be able to set it's "Group" property.
This means that every button with an Id greater than this button's will be part of the group. This applies to all buttons folowing, unless another button with the "Group" property set follows. Every button after that will be in the second group. Since you created the radio buttons dinamically, I think they all default to one group (I'm not sure how/whether you can change this behaviour). As to the other question, I sometimes use a different mechanism to see which button is checked - maybe you can use it as well, although it's kind of a hack... I just use a flag variable - which could be a member of your dialog - and implement each buttons OnClick event. In each implementation I set the flag's value to the number of the button (0, 1, 2, ...). When I want to know which button is checked, I just test this flag! Of course, in this case the implementation can be much more elegant using ON_COMMAND_RANGE I changed your chosen ID's to more reasonable ones and defined the first one to a default value of 111. Let's see what we have; first, define this value: CPP / C++ / C Code:
Then, in your OnInitDialog: CPP / C++ / C Code:
Let's now map a method - lets say OnRadioClicked on the created buttons (just add the line I did): CPP / C++ / C Code:
Now lets tell him who the new method is: radioDlg.h CPP / C++ / C Code:
Now lets implement the new method: CPP / C++ / C Code:
Of course, this is a stupid example; just something to get you going Hope this is helpfull enough.... Kind regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#3
|
|||
|
|||
|
Quote:
thanks! looks like i really need to look over message maps!! do you know any good tutorials for them? thanks. |
|
#4
|
||||
|
||||
|
Well, when it comes to VC, I usually just point to the msdn
However, I also recommend this great tutorial - all you have to do is do a search on MESSAGE_MAP once you opened the page in your browser. I am confident you will find all you need to know here! For further questions, you are welcome to post here! P.S: I will have to ask you to use the code tags in your posts as I suggested. For further info on this please direct your browser to this page Thank you. Best regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#5
|
|||
|
|||
Re: radio buttonsThis is a good example for adding single event - handler for radio button
Regard Rajesh |
Recent GIDBlog
Programming ebook direct download available by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| collecting user input from radio buttons. | Adelle29 | Web Design Forum | 1 | 31-May-2004 17:28 |
| windows media player internet radio | Hood | Computer Software Forum - Windows | 0 | 02-May-2004 03:58 |
| GIDForums MemberRank buttons. | JdS | GIDForums™ | 2 | 24-Jan-2004 22:35 |
| radio button problem | zuzupus | MySQL / PHP Forum | 1 | 08-Aug-2003 04:25 |
| GIDTopsites buttons | jrobbio | GIDTopsites™ | 0 | 26-Mar-2003 09:08 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The