CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Posts
    26

    Disabling/Enabling all controls

    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.


  2. #2
    Join Date
    May 1999
    Posts
    82

    Re: Disabling/Enabling all controls

    Try this

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





  3. #3
    Join Date
    May 1999
    Posts
    26

    Re: Disabling/Enabling all controls

    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


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