almorris
asked on
Grouping Radio buttons
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",ps zRos[m_nNe xtItem], SS_RIGHT | WS_CHILD | WS_VISIBLE, x, 30 + y,280,25,m_hReport_Patient Ros,NULL,h Inst,NULL) ;
//Group these
//--------------------
m_hGroup[i] = ::CreateWindow("BUTTON","" , BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 280 + x, 20 + y, 40,30,m_hReport_PatientRos ,NULL,hIns t,NULL);
m_hROS_Yes[i] = ::CreateWindow("BUTTON","" , BS_AUTORADIOBUTTON| WS_CHILD | WS_VISIBLE, 286 + x, 30 + y, 14,14,m_hReport_PatientRos ,NULL,hIns t,NULL);
m_hROS_No[i] = ::CreateWindow("BUTTON","" , BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 304 + x, 30 + y, 14,14,m_hReport_PatientRos ,NULL,hIns t,NULL);
//-------------------
//Set default Checks
if (m_bRos[m_nNextItem] == true)
{
::SendMessage(m_hROS_Yes[i ],BM_SETCH ECK,BST_CH ECKED,0);
}else{
::SendMessage(m_hROS_No[i] ,BM_SETCHE CK,BST_CHE CKED,0);
}
m_nNextItem ++;
y += 25;
if (m_nNextItem > 52) break;
}
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",ps
//Group these
//--------------------
m_hGroup[i] = ::CreateWindow("BUTTON",""
m_hROS_Yes[i] = ::CreateWindow("BUTTON",""
m_hROS_No[i] = ::CreateWindow("BUTTON",""
//-------------------
//Set default Checks
if (m_bRos[m_nNextItem] == true)
{
::SendMessage(m_hROS_Yes[i
}else{
::SendMessage(m_hROS_No[i]
}
m_nNextItem ++;
y += 25;
if (m_nNextItem > 52) break;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER