Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Simple radio button question

Posted on 1998-12-02
12
Medium Priority
?
301 Views
Last Modified: 2013-11-20
All i have is three radio buttons in a dialog box.. how do i figure out which one was selected after the user presses OK?
0
Comment
Question by:rabbitears
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1325670
Look at the GetCheck method of the radio buttons and the DDX_Radio AFX method.

Cheers,

Raymond.
0
 
LVL 2

Expert Comment

by:wyy_cq
ID: 1325671
specify them in a group.
and you can add a member variable of int associated with them.
call UpdateData(TREU);
the int variable is the zeroBase index of the selected item.

or you can get all the button hWnd(CWnd*) and call their GetCheck().

eg:
OnOK()
{
CButton* pB1=(CButton*)GetDlgItem(IDC_XXX1);
int iC=pB->GetCheck();
CButton* pB2=(CButton*)GetDlgItem(IDC_XXX2);
int iC2=pB->GetCheck();
CButton* pB3=(CButton*)GetDlgItem(IDC_XXX3);
int iC3=pB->GetCheck();

// if the return value is 1, the button is checked
}


0
 

Author Comment

by:rabbitears
ID: 1325672
yeah, but i can't create member variables with the class wizard for some reason.. am i doing something wrong? i was sure it had something to do with ddx, but...
0
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

 

Expert Comment

by:McCreary
ID: 1325673
If you can't create member variables with the class wizard, it is likely that your app.clw file is corrupted.  Just delete it.  Next time you go into the class wizard it will ask you if you want to build the clw from your files.  Respond with a hearty YES.
0
 

Expert Comment

by:madhav102398
ID: 1325674
yes, like McCreary says that might be a reason.
it might be even sometimes because your source code files, i mean .cpp & .h files are read-only, then the class wizard will have its "Add Variable" button greyed out. Is that your problem when you say, you cannot add member variables?
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1325675
I like to do this

BOOL bRadio1 = IsDlgButtonChecked( IDC_RADIO1 ) ;
BOOL bRadio2 = IsDlgButtonChecked(IDC_RADIO2 ) ;
// etc.
0
 

Expert Comment

by:adresko
ID: 1325676
here's the deal. i've created the radiobuttons with the resource editor.. thing is, when i go to classlizard to add member variables, the radiobutton id's aren't even in the list for the to choose! i even rebuilt the .clw file.. to no avail.. :(
0
 

Expert Comment

by:t004024
ID: 1325677
Declare an integer variable in U'r dialog class, override the BN_CLICKED event of the radio buttons and set the variable to the clicked button number.

When OK is pressed, check this variable value to get the radio button selected.

I don't think U can associated member variables with radio buttons, U can associate them only with check buttons.

0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1325678
adresko - you don't need to add a member variable to the class to use my solution
0
 
LVL 4

Expert Comment

by:pagladasu
ID: 1325679
With your resource editor, check the group property of the first radio button in the set. Then using class wizard you can associate an integer member variable with this button.
After this follow the way wwy_cq has suggested.
thanks
pagladasu
0
 
LVL 1

Accepted Solution

by:
The_Brain earned 100 total points
ID: 1325680
The radio buttons, Do the BN_CLICKED.
But there are problems with this.  The poor guys might chop and change his mind, so. I suggest,

BeenClicked (radio1)
{
   m_Clicked1=1;  //create it yourself in the grey area. Or
   m_clicked2=0;
   m_Clicked3=0;  //this is to cancel previous selections.
}
hope this is what you are wanting, the trick is to make your own variables.  (not always generated :)
These variables should be in the Public section of About thing, you can't really miss it.  If you want a better and even a demonstration program I will do this.  Gimme a beep on zd13@pipex.co.za or g_dutoit@hotmail.com

where the other members are created.  and in the DDX (maybe) try witout that first.


}
0
 

Author Comment

by:rabbitears
ID: 1325681
what the heck, it's only 50 points..
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question