Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GetNextDlgGroupItem

134 views
Skip to first unread message

Paul Baker

unread,
Feb 28, 2003, 9:20:18 PM2/28/03
to
Help!

I have a set of radio buttons and a check box. If the check box is checked
then then both radio button controls should be "enabled". If the check box
is not checked then both radio button controls should be "disabled".

I have the following code:

CWnd* NxtButton = &m_Lbl_Relabel_All_Crtl;

m_Lbl_Relabel_All_Crtl.EnableWindow(EWswitch1);
NxtButton = GetNextDlgGroupItem(NxtButton);
NxtButton->EnableWindow(EWswitch1);

m_Lbl_Relabel_All_Crtl is the control of the first button in the two button
control group.
EWswitch1 is set to either TRUE or FALSE. When EWswitch1 is set to FALSE the
processing works and both buttons in the control group are dimmed
(Disabled). But the next pass thru when EWswitch1 is set to TRUE then only
the first button in the two button control group is Enabled. The second
button where the address is retrieved using GetNextDlgGroupItem is not
enabled.

Does anyone know what is wrong with the above code?

Any help would be appreciated!!!!!

Thanks, Paul


David Lowndes

unread,
Mar 1, 2003, 8:02:20 AM3/1/03
to
>EWswitch1 is set to either TRUE or FALSE. When EWswitch1 is set to FALSE the
>processing works and both buttons in the control group are dimmed
>(Disabled). But the next pass thru when EWswitch1 is set to TRUE then only
>the first button in the two button control group is Enabled. The second
>button where the address is retrieved using GetNextDlgGroupItem is not
>enabled.

Paul,

The documentation for GetNextDlgGroupItem says:

"the function returns the first control it locates that is visible and
not disabled."

Why don't you just directly enable/disable the controls by their IDs?

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq

Paul Baker

unread,
Mar 1, 2003, 1:47:15 PM3/1/03
to
> Why don't you just directly enable/disable the controls by their IDs?

I'm still learning C++ and MFC... and there are still some fundamental
things that I don't know or understand.... Will you please give me an
example of how to reference a control by it's ID?

Thanks, Paul


David Lowndes

unread,
Mar 1, 2003, 3:17:59 PM3/1/03
to
>I'm still learning C++ and MFC... and there are still some fundamental
>things that I don't know or understand.... Will you please give me an
>example of how to reference a control by it's ID?

It's as simple as:

GetDlgItem( IDC_WHATEVER )->EnableWindow( ... );

Ian Semmel

unread,
Mar 1, 2003, 3:25:52 PM3/1/03
to
Forget about grouping the items.
Have a control for each item (via ClassWizard)
CButton c_CheckBox
CButton c_Radio1
CButton c_Radio2

In your c_CheckBox Button Clicked handler

if ( c_CheckBox.GetCheck () != 0 )
{
c_Radio1.EnableWindow (TRUE );
c_Radio2.EnableWindow (TRUE)
}
else
{
c_Radio1.EnableWindow (FALSE );
c_Radio2.EnableWindow (FALSE)
}
You can make this code a bit smarter by setting the enable window value to
the state of the checkbox.

"Paul Baker" <pbak...@mindspring.com> wrote in message
news:b3qv...@enews1.newsguy.com...

Paul Baker

unread,
Mar 1, 2003, 5:13:52 PM3/1/03
to
Thanks very much guys! I think that:

GetDlgItem( IDC_WHATEVER )->EnableWindow( ... );

will work for me... I'm already using the ClassWizard to set assign
variables to the dialog items. The problem that I was having was that the
"Wizard" only privides a variable for the "control" radio button. I got
around the problem by making both radio buttons control buttons and then
assigned names to the variables. Then I cleared the control check on the
second radio button.

Anyway... thanks for the help!!!!!

Paul

"Ian Semmel" <ise...@rocketcomp.com.au> wrote in message
news:u$aO7CD4C...@TK2MSFTNGP10.phx.gbl...

Joseph M. Newcomer

unread,
Mar 3, 2003, 3:05:53 AM3/3/03
to
Check out my essays on dialogs on my MVP Tips site.

What I do is assign a contol variable for each button I want to enable/disable.

The problem is a fundamental stupidity on the part of Microsoft. With no justification
whatsoever, they have unilaterally determined that I could *never possibly* want a control
variable for a radio button that doesn't have a WS_GROUP flag set (an inexcusable attitude
which has persisted into VS7, in spite of its fundamental stupidity). So you have to set
the WS_GROUP attribute of all the radio buttons, which allows you to create control
variables for them, then remove the WS_GROUP attribute from all but the first. Fortunately
this is easy. You multiselect all the radio buttons, then click the "Group" checkbox in
the Properties box. Then bring up ClassWizard, create all the variables you want, close
ClassWizard, uncheck the "Group" checkbox (you have presumably done nothing to change the
multiselect), deselect all the buttons by clicking somewhere esle on the form, then select
the first button again and select the "Group" atribute. You can then do

BOOL enable = c_MyCheckBox.GetCheck() == BST_CHECKED;

c_FirstRadioButtonWhateverYouCalledIt.EnableWindow(enable);
c_SecondRadioButtonWithANiceName.EnableWindow(enable);

and so on.
joe

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm

Joseph M. Newcomer

unread,
Mar 3, 2003, 3:07:56 AM3/3/03
to
As I pointed out, this is an irresponsible decision which has not yet been fixed in VS7.
It makes no sense whatsoever, except in the case where you consider the very limited
situation in which you might want to use the Microsoft means of detecting what radio
button is checked, which is pretty useless most of the time. One of those "attitude"
problems where they "know better than you do" what you could possibly want. What I can't
figure out is why such a ridiculous decision has not been fixed after all these years!
joe

Joseph M. Newcomer [MVP]

0 new messages