Solved

Grouping Radio buttons

Posted on 2004-04-08
3
912 Views
Last Modified: 2011-10-03
Hi all...

I am displaying 20x2 radio buttons as choices on a window.  The radio's are Yes & No x 20.  I have tried everything but every time I click on one all the others are affeced.  I know that I have to group each pair but this is not working for me ... Here is the code maybe you guys/gals have some ideas.  Thanks Aaron.

for(i = 0; i < 20; i ++)
{
//formatting stuff      
if (i == 10)
{
 x = 320;
 y = 0;
}

m_hROS_Statics[i] = ::CreateWindow("STATIC",pszRos[m_nNextItem], SS_RIGHT | WS_CHILD | WS_VISIBLE,  x, 30 + y,280,25,m_hReport_PatientRos,NULL,hInst,NULL);
            
//Group these
//--------------------
m_hGroup[i] = ::CreateWindow("BUTTON","",  BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 280 + x, 20 + y, 40,30,m_hReport_PatientRos,NULL,hInst,NULL);
m_hROS_Yes[i] = ::CreateWindow("BUTTON","",  BS_AUTORADIOBUTTON| WS_CHILD | WS_VISIBLE, 286 + x, 30 + y, 14,14,m_hReport_PatientRos,NULL,hInst,NULL);
m_hROS_No[i] = ::CreateWindow("BUTTON","",  BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 304 + x, 30 + y, 14,14,m_hReport_PatientRos,NULL,hInst,NULL);
//-------------------


//Set default Checks
if (m_bRos[m_nNextItem] == true)
{
 ::SendMessage(m_hROS_Yes[i],BM_SETCHECK,BST_CHECKED,0);
}else{
 ::SendMessage(m_hROS_No[i],BM_SETCHECK,BST_CHECKED,0);
}
      

m_nNextItem ++;
y += 25;
if (m_nNextItem > 52) break;
            
}
0
Comment
Question by:almorris
[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
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
wayside earned 140 total points
ID: 10786640
Add WS_GROUP property to all the yes buttons:

m_hROS_Yes[i] = ::CreateWindow("BUTTON","",  BS_AUTORADIOBUTTON| WS_CHILD | WS_VISIBLE | WS_GROUP, 286 + x, 30 + y, 14,14,m_hReport_PatientRos,NULL,hInst,NULL);

0
 

Author Comment

by:almorris
ID: 10786691
Wow .. Thanks wayside for the quick response !!!
0
 
LVL 14

Expert Comment

by:wayside
ID: 10786708
To explain -

All controls created without WS_GROUP that are created after a control that was created with WS_GROUP, are grouped with the control that has WS_GROUP.

Creating another control with WS_GROUP starts a new group.

So adding WS_GROUP to all the yes buttons will create  groups of two buttons.

I suppose you could add WS_GROUP to the group buttons (maybe that's what you were trying to do with WS_GROUPBOX; I never heard of WS_GROUPBOX anyway), but since the group buttons are regular buttons, it doesn't really matter what group they are in.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Handle Exceptions during instantiation 28 429
Focus not getting shifted out of  editbox 2 69
Find Visual Studio Tools 2 121
Why isn't object file created? 6 90
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

749 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