Radio Buttons don't work.

  • Thread starter Thread starter Peter Aitken
  • Start date Start date
P

Peter Aitken

I am working on a VC++ program in VS.Net 2003. I am following the
instructions in the help for putting a group of radio buttons on a form.

1) Put 3 radio buttons on the form.
2) Make sure they are seqential in the tab order.
3) For the first one in the tab order, set the Group property to true.
4) Right click the first one in the tab order and select Add variable.
5) Select the Control check box.
6) From the Category list select value.
7) Enter a name for the variable.
8) From the Variable Type list select int.

It's the last step that is throwing me - the list offers only type BOOL. How
can a type BOOL give me info on which of 3 radio buttons is selected? What
am I doing wrong?

Thanks,
 
I am working on a VC++ program in VS.Net 2003. I am following the
instructions in the help for putting a group of radio buttons on a form.

1) Put 3 radio buttons on the form.
2) Make sure they are seqential in the tab order.
3) For the first one in the tab order, set the Group property to true.
4) Right click the first one in the tab order and select Add variable.
5) Select the Control check box.
6) From the Category list select value.
7) Enter a name for the variable.
8) From the Variable Type list select int.

It's the last step that is throwing me - the list offers only type BOOL. How
can a type BOOL give me info on which of 3 radio buttons is selected? What
am I doing wrong?

You have to check the state of each button (or at least 2 of the 3,
and assume that if neither is, then it is 3). Only one should be
selected.

Pseudocode:

if (button1 is checked)
checked_button = 1
else if (button2 is checked)
checked_button = 2
else
checked_button = 3

I wrote a C variadic function that will take any number of button IDs
and return the ID that is selected, but I don't have the code
available to show right now.

There may be shortcuts to this in MFC, but I don't use it.
 
Severian said:
You have to check the state of each button (or at least 2 of the 3,
and assume that if neither is, then it is 3). Only one should be
selected.

Pseudocode:

if (button1 is checked)
checked_button = 1
else if (button2 is checked)
checked_button = 2
else
checked_button = 3

So I'd attach a BOOL to each button and check each one individually?

Thanks,

Peter
 
Peter Aitken said:
I am working on a VC++ program in VS.Net 2003. I am following the
instructions in the help for putting a group of radio buttons on a form.

1) Put 3 radio buttons on the form.
2) Make sure they are seqential in the tab order.
3) For the first one in the tab order, set the Group property to true.
4) Right click the first one in the tab order and select Add variable.
5) Select the Control check box.
6) From the Category list select value.
7) Enter a name for the variable.
8) From the Variable Type list select int.

It's the last step that is throwing me - the list offers only type BOOL.
How can a type BOOL give me info on which of 3 radio buttons is selected?
What am I doing wrong?

Thanks,
The key phrase in the help article you missed is:

"In the Variable type list box, select int or ***type*** int."

(Asterisks added for emphasis).
If you type "int" into the combo box, your variables will be created as
described.
 
Back
Top