Click to See Complete Forum and Search --> : How to make a modal dialog temporarily go away


Kevin Kelly
April 8th, 1999, 01:39 PM
I have a modal dialog which I need to push out of the way for a few moments so the user can interact with the main window in the same application. How can I do this? I can't use a modeless dialog because I need to hold up processing until the dialog closes. Any ideas?

Kevin

Daniel Levine
April 8th, 1999, 01:45 PM
Perhaps you could use ShowWindow(SW_HIDE) to hide the dialog, then ShowWindow(SW_SHOW) to bring it back.

Daniel.

Kevin Kelly
April 8th, 1999, 02:06 PM
That will hide the dialog, but it still holds the input focus away from other windows in the same application.

Daniel Levine
April 8th, 1999, 05:18 PM
Perhaps you could integrate whatever it is that is being done in the main window into the dialog.

April 8th, 1999, 08:47 PM
Just call "CWnd::EnableWIndow()" on the parent or whatever window you want to re-enable (passing TRUE) and pass it FALSE again when done.

Paul McKenzie
April 9th, 1999, 01:38 AM
You can't interact with the main application if
the dialog is modal. That's the definition of
modal. What you want to do is not what a modal
dialog was designed for. Unless you want to get
into some real low-level programming, a modal
dialog will always keep the focus until the
dialog is closed.

Unless if I'm wrong, the reason for this is that
a modal dialog has its own local message pump.
The main app message pump is disabled. Therefore
all messages are blocked from the main
application.

What you want is either to redo the
interface, or create a modeless dialog and
programatically control how things work if the
dialog is visible or shut down. You may not have
known it, but you gave yourself the hint as to
how to solve this problem ("I need to hold up
processing until the dialog closes") ;-)

For example, when you display the modeless
dialog, send a user-defined message to your app
that whatever processing should stop. When the
user closes the dialog, send another user defined
message (maybe even the same message with a
different wParam or something) notifying that
processing should start again.

Take it from there.

Regards,

Paul McKenzie