Disable all controls in a dialog box.
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
Re: Disable all controls in a dialog box.
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
Re: Disable all controls in a dialog box.
This is the code for a specific dialog box.
Can I have a common code which works for
every dialog box.
Regards,
pabitra
Re: Disable all controls in a dialog box.
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