Does MFC have Member Variable for RadioButton? [Resolved]
The RadioButton is present in the Controls palette as well as other familiar controls. But I can't assign a member variable to the radio button although I can to the other controls (I've used -- Button, EditBox StaticText).
I've assigned them their own ID "IDC_RADIO1_LAN" and another as "IDC_RADIO2_Internet", but they don't show up in the ClasWizard Control ID's under the Member Variables tab. The Object ID's exist un the Message Maps tab.
Shouldn't I be able to get something like m_LAN.Checked=TRUE or m_Internet.Checked=FALSE ? (Where m_~~~ is my assigned member variable)?
I saw a few other MFC threads. Looks like we don't like MFC here. I decided to try it again after I got pretty good at Java. I'm trying to get a chat program going in MFC. I was successfull in VB and Java but actually my disappointment in MFC led me to learn Java and hate MS. But now I crave the speed of C++. The scribble tutorial is making sense now, but I didn't go through it all--only enough to get started again. I seem to have missed the radiobutton example.
Can I put two radiobuttons on a form (dialog) without a group box?
Anyway, I added a group box after I had the two radiobuttons and then put them on the groupbox. I was able to get a member variable for the groupbox, but I didn't see a property for what I need. It's probably too obscure for me (like SetWindowText was to me for a CButton when I first started).
Does it matter the order I add controls to the dialog? If I recall correctly VB preferred that I draw a radiobutton control on top of an existing groupbox, and the order was a pain. Like I said, I added the groupbax after the radiobuttons.
I'm starting to like MFC. But actually, I restarted a new project yesterday (that I had begun a week ago) because I couldn't remove something that screwed up my current compile. Everything was great until I must have made a change that I don't recall what it was. So I couldn't undo the change. Another thing was I couldn't remove a class I had added (even though I think there was an 'exclude from compilation' option). Any advice will be appreciated.
You need a member variable for the first radiobutton
That's why I posted this thread. I don't know how to get a member variable for a radio button, although I can get one for other objects. I went with checkboxes, but I shouldn't have had to.
There was something about setting/checking the "Group" property and the tab order on the resource editor, but I didn't grasp it (or it's another M$ bug) -- it didn't work out for me.
I removed classes manually and it seemed to work (the wizard seemed to become aware of the fact), but then the file seemed to come back. Perhaps it was after a "find in files" and the class was still in the folder. Maybe I needed to delete the file (at least from that folder as well). But I thought it was removed from the project. Oh well.
If you figure out the group thing, please let me know. It's kind of corny to try mutually exclusive options with check boxes.
Here's about the radio control. Attached is an MFC project. The "About" dialog contains two radio boxes, mutually exclusive. It has a member variable for the first of the two radios (control variable) and another for the whole group (data variable, which one is selected).
If VC++ misses files, tell me. I did not include the ones I thought to be unnecessary.
All the buzzt CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Checking the Group property allows a member variable to be set for a radio button
Thanks for your efforts. I'll also be posting a new MFC headache I'm having soon.
I didn't compile your code because the problem I have is seeing the Control ID appear in the ClassWizard under the Member Variable tab in the first place. In fact, I don't see your "IDC_RADIO2" there either. How were you able to create any member variable for the radiobutton?
I see your IDC_RADIO2 Object ID under the Message Maps tab in ClassWizard and I see a IDC_RADIO3 when I add a third radio button control.
As far as saving the workspace, maybe you have a point there; I generally just hit a build option which says "the file is out of date, do you wish to rebuild them?"
I just compiled your code, but I guess I didn't have to. I'm sort of getting it now. It is about which control has the "Group" checkbox set in the Properties box for that control. If I knew what I was doing, your first answer would have sufficed
From the Help:
Group
Specifies the first control of a group of controls in which the user can move from one control to the next by using the arrow keys. All controls in the tab order after the first control with the Group property set to False belong to the same group. The next control in the tab order with Group set to True ends the first group of controls and starts the next group. Type: Bool. Default: False.
I was setting the GroupBox as having the Group property check box set and I wasn't finding a member variable for the radiobuttons. Now I see from your settings that I shouldn't care about the group graphic, and I should just set a radio button with the group property set, then I'll have a member variable(s) for the radio. Thanks!
The resolution is:
Checking the Group property for a radio button in this resource Properties dialog box allows a member variable to be set for this radio button.