Click to See Complete Forum and Search --> : Disabling/Enabling all controls


Sergio Acosta
May 30th, 1999, 12:56 AM
Does somebody knows a way to enable/disable all the controls in a dialog at the same time?.

I have done it with a for :

for(int i = ID_FIRST_CONTROL; i<=LAST_CONTROL;i++)
{
GetDlgItem()->EnableWindow(FALSE);
}




but i hate to number secuencially all the resources in the Resource.h every time i add a new control, despite i have a macro that does it.

I've tried the CWnd::GetWindow(GW_CHILD) function, but I haven't had it to work.

I hope you could point me in the right direction.
Tank you very much.

Dan Haddix
May 30th, 1999, 01:15 PM
Try this

CWnd* wnd = GetTopWindow( );
while(wnd){
wnd->EnableWindow(FALSE);
wnd = wnd->GetNextWindow();
}

Sergio Acosta
May 30th, 1999, 03:33 PM
Tank you very much, it worked great. I only had tried with GetWindow(GW_CHILD) and GetWindow(GW_HWNDNEXT) but I had never tried what you suggested.

By the way, I missed an ŽiŽ in the GetDlgItem(i) in my question, for those who were wondering how the heck it worked :)