[Visual C++] Assistant AppWizard / bouton radio
skarsnick
Posted messages
79
Status
Member
-
itachi -
itachi -
Hello, I am currently creating a form in Visual C++
and I have a technical issue.
To keep it simple, let's take an example:
I ask the question:
Male or female? If you check Male, I would like a radio button located on the same page to be checked.
In short, how can I check a radio button through code and not with the mouse?
Do you have any ideas?
Thank you
and I have a technical issue.
To keep it simple, let's take an example:
I ask the question:
Male or female? If you check Male, I would like a radio button located on the same page to be checked.
In short, how can I check a radio button through code and not with the mouse?
Do you have any ideas?
Thank you
Configuration: Windows XP Internet Explorer 7.0
6 answers
Good, to be more precise and especially to try to be clearer:
When you work with MFC and Visual Studio, you can group radio buttons.
Step by step, it goes like this:
1/Edit your "form" to add a first radio button.
2/Right-click on this radio button, display the properties, and check "Group".
3/Then add your other radio button(s) that are part of the same group, but this time without checking "group" in the properties, otherwise it would start a new group.
4/Go to Class Wizard by right-clicking on your form. In the "variables" tab, select the button corresponding to the ID of the first radio button in your group and associate a variable with it.
5/If later you do:
tavariable=0 you will select the first button
tavariable=1 you will select the second button and so on.
Just don't forget to do "UpdateData(FALSE);" in the following lines to refresh the display of your window according to your changes.
There you go, I hope this was clearer, if not, don't hesitate to ask.
Good luck.
Andejen
--
"Dido later will be my wife," Stupeflip
When you work with MFC and Visual Studio, you can group radio buttons.
Step by step, it goes like this:
1/Edit your "form" to add a first radio button.
2/Right-click on this radio button, display the properties, and check "Group".
3/Then add your other radio button(s) that are part of the same group, but this time without checking "group" in the properties, otherwise it would start a new group.
4/Go to Class Wizard by right-clicking on your form. In the "variables" tab, select the button corresponding to the ID of the first radio button in your group and associate a variable with it.
5/If later you do:
tavariable=0 you will select the first button
tavariable=1 you will select the second button and so on.
Just don't forget to do "UpdateData(FALSE);" in the following lines to refresh the display of your window according to your changes.
There you go, I hope this was clearer, if not, don't hesitate to ask.
Good luck.
Andejen
--
"Dido later will be my wife," Stupeflip
I saw that by doing:
(Cbutton*)GetDlgItem(IDC_Radio1))->SetCheck(1); it checked my button, I've never done C++, I'm struggling a bit here.
So we can attach a variable to buttons?
That would be really handy :)
I'll try to look for it.
(Cbutton*)GetDlgItem(IDC_Radio1))->SetCheck(1); it checked my button, I've never done C++, I'm struggling a bit here.
So we can attach a variable to buttons?
That would be really handy :)
I'll try to look for it.
Bonjour à tous, je souhaite lancer une MFC je ne sais pas par où commencer ! Déjà, utiliser quel outil ? Où le trouver ? Merci de m'aider.
Hello
I am currently developing an application with MFC in Visual C++ 6.0. When I used OnOK() to close the form in the MDI, it did not work in the form, whereas it works in a dialog box. If someone has the answer, please let me know.
If anyone is developing applications in Visual C++ and wants to help each other, I leave my email address rachid@steve.com
I am currently developing an application with MFC in Visual C++ 6.0. When I used OnOK() to close the form in the MDI, it did not work in the form, whereas it works in a dialog box. If someone has the answer, please let me know.
If anyone is developing applications in Visual C++ and wants to help each other, I leave my email address rachid@steve.com
Actually, radio buttons work in groups. So if you group your female button + your male button, you just need to assign a variable to the first of the buttons with Application wizard. Then, if you want to select the first in the group, you set your variable = 0, and to select the second your variable = 1.
NB: I know it's not clear, but I don't have time to stay. If it's incomprehensible, I'll repost tomorrow.
--
"Dido, later she will be my wife," Stupeflip
NB: I know it's not clear, but I don't have time to stay. If it's incomprehensible, I'll repost tomorrow.
--
"Dido, later she will be my wife," Stupeflip