Disabling an MFC Window

Started by
0 comments, last by DisKordCoder 22 years, 10 months ago
Im currently working on a Dialogue based MFC application. And for a short moment while the software is saving (or loading) a file, i need the whole window to be disabled from user interaction. How can i apply this effect? Ive seen it before, when the windows buttons and white areas go grey to say they are not active. Can anyone help me on this, ive been looking for an answer for quite some time.
Advertisement
The input loop is frozen if you don''t process messages, so one fairly rude method of doing this is to put a wait cursor (hourglass) up at the beginning of the message handler, do all your processing inside the handler, then put the cursor back to normal. MFC makes this easy with "CWaitCursor". Just drop the line "CWaitCursor cursor;" at the top of lengthy message handlers--its constructor makes the cursor into the hourglass, and its destructor puts it back.

However, to individually enable and disable controls, you can always use CWnd::EnableWindow (bEnable). Setting bEnable to FALSE will give you the greyed-out look you want, and it won''t accept user input. You have to call it for each control you want to enable/disable (I believe, never tried doing it for the parent and seeing if it went to all children).

This topic is closed to new replies.

Advertisement