Click to See Complete Forum and Search --> : Disable all controls in a dialog box.
October 19th, 1999, 02:52 AM
Hi,
I want to disable all the controls in dialog box. I can manually disable by taking the ID of every controls.
But I do not want to do like this. How can i get the handle of first dialog box control. Then in a loop
I will disable the the controls.
Please Help.
Regards,
Pabitra
Martin Speiser
October 19th, 1999, 02:54 AM
Hi Pabitra,
this is how I did it in a class derived from CPropertyPage.void PropertyPage::EnableAllControls( BOOL bEnable /* = TRUE */ )
{
CWnd* pwndChild = GetWindow( GW_CHILD );
while ( pwndChild )
{
pwndChild->EnableWindow( bEnable );
pwndChild = pwndChild->GetNextWindow( GW_HWNDNEXT );
}
}
Works the same way in a CDialog derived class.
Martin
October 19th, 1999, 05:54 AM
This is the code for a specific dialog box.
Can I have a common code which works for
every dialog box.
Regards,
pabitra
Martin Speiser
October 19th, 1999, 05:56 AM
Hi,
that's easy. Derive a class from CDialog, for instance CMyDialog, add the function, and use it where you would normally use CDialog.
That's how we did it in our project. We don't derive from CPropertyPage, but from our PropertyPage.
Martin
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.