CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Guest

    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


  2. #2
    Join Date
    Apr 1999
    Location
    Germany
    Posts
    418

    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

  3. #3
    Guest

    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


  4. #4
    Join Date
    Apr 1999
    Location
    Germany
    Posts
    418

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured