CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2009
    Posts
    84

    [MFC] Enable/Disable all controls in propertypages

    Hello everyone!!

    I'd like to enable/disable all controls in some propertypages and I thought for this solution put in a common header included in all propertypages to avoid duplication code and without need to know necessarily which controls there are in each page:

    BOOL CALLBACK DisableAllChildren(HWND hwnd,LPARAM) {
    EnableWindow(hwnd,FALSE);
    return TRUE;
    }

    void DisableControls(HWND hDlg) {
    EnumChildWindows(hDlg,(WNDENUMPROC)DisableAllChildren,0);
    }

    where to disable, I could call as:

    DisableControls( GetDlgItem(IDD_MODULES_PROPPAGE)->GetSafeHwnd() );

    but I get this error:

    error C3867: 'CCommonHeader:isableAllChildren': function call missing argument list; use '& CCommonHeader:isableAllChildren' to create a pointer to member

    Reading an article on CodeProject I read also this technique isn't thread-safe if I have multiple threads doing the enumeration...

    So how I can get to disable/enable all controls in pages safely?...

    Thanks to everyone for the little help!!!
    Ciao,
    Luigi

  2. #2
    Join Date
    Jul 2002
    Posts
    2,543

    Re: [MFC] Enable/Disable all controls in propertypages

    EnumChildWindows requires global function in lpEnumFunc parameter. Declare DisableAllChildren function as static.

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