Programming Tips - How can I easily disable or enable all controls in a Dialog?

Date: 2009may1 Platform: win32 Language: C/C++ Keywords: children, child Q. How can I easily disable or enable all controls in a Dialog? A.
// Helper function static BOOL CALLBACK GotAChild(HWND hwnd, LPARAM bEnable) { EnableWindow(hwnd, bEnable); return TRUE; } void EnableChildren(const HWND hwnd, const BOOL bEnable) { EnumChildWindows(hwnd, GotAChild, bEnable); } // Example use... from OnClose() of an MFC application: EnableChildren(GetSafeHwnd(), FALSE);