Disable all child window controls(ie. grayout)

I need to disable all the child controls in a window (say dialog).

For example, say I have a CMyDialog (derived from CDialog) class having
CComboBox myCombo1; ... myCombo100;
CListBox myListBox1; ... myListBox100;

All these variable number of combo, listbox, edit controls get displayed in the Dialog.

At run time I need to Gray them out (disable) them.

What is the most generic way of doing that? (I know myComboBox->EnableWindow(False) etc.. but it won't work in my case because I donot want to hardcode these variable names in my program to diable them.

I want to know a generic way of sending message to ALL visible child controls of a dialog to diable (& grayout) themself.

Any code sample would be very helpful.

Venkatesan Pillai
Senior Software Engineer, Autodesk Inc
San Rafael, CA 94903

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can use CWnd::GetNextDlgTabItem() and/or CWnd::GetNextDlgGroupItem() to enumerate all the child controls. Pass NULL as the pWndCtl parameter to get the first control.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.