Dave's Brain

Browse - programming tips - enable disable child windows

Date: 2009may1
Platform: win32
Language: C/C++

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);
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2010, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.