Archived

This topic is now archived and is closed to further replies.

DisKordCoder

Disabling an MFC Window

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites