tags:

views:

167

answers:

1

Hi, How do I disable all the controls in a dialog window ? I know I could use EnableWindow(FALSE); but this doesnt seem like a good idea because now there is no way for the user to click "Ok" or "Cancel" button or press the "X" icon to exit. The dialog is like frozen.

What I am looking for is a way to disable all the controls in a dialog while providing some way for a user to exit.

Another solution is to do it manually by going through all the dialog controls and disabling them but this gets tedious. Any easy way ?

Thanks.

+3  A: 

Sorry, but going through all of the controls and disabling each of them is the easy way.

You can write a general function to do this using EnumChildWindows or using a loop calling GetWindow(... GW_HWNDNEXT) until it returns NULL for the next window.

Just remember to skip disabling the window that has the IDCANCEL as the id.

John Knoeller
Yep, this is correct.
mwigdahl
And don't forget: never, ever disable the control which has the focus! If you have to disable that control, first pass the focus on to another control, *then* disable it.
Stefan