Disable all child window controls(ie. grayout)

Posted on 1998-01-25
Last Modified: 2013-11-20
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

Question by:dvenkat
1 Comment
LVL 23

Accepted Solution

chensu earned 30 total points
ID: 1314764
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.


Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand macro to ask for filename column 8 37
move a line in eclipse 3 100
EvenOdd challenge 10 107
firstChar challenge 13 115
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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

785 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