Force dialogs to move down in Z order

Is there any way to let a dialog move down in the Z-order, in other words to let a different window in the same app take over the top of the z-order and be shown in front of the dialog?  How can I do this?

My backup plan is to use a CWnd instead of a dialog, but if I do that, how hard is it to implement it to act like a dialog?
Who is Participating?
ZoppoConnect With a Mentor Commented:
Hi appleby,

I think it's only possible with modeless dialogs, simply create it with the desktop as parent, i.e.

m_pMyDlg->Create( CMyDlg::IDD, GetDesktopWindow() );

hope that helps,

Vinayak KumbarSr Program ManagerCommented:

U can do that by using the modeless dialogs.
Instead of calling DoModal(), call Create like..

declare for that class in .h file
CDialog *m_pDialog;

m_pDialog = new CDialog;
m_pDialog->Create(NULL, IDD_DIALOG1);

Now, if u click on the main window, then the dialog will go back. Similar logic can be applied if u want to dialogs to behave like that. ie one in modaled and it creates another and that dialog should go behind on activating the main dialog.

Try it out.
applebyAuthor Commented:
Nope, that just makes the dialog lose focus, it doesn't allow you to bring MDI child windows (open documents within the application for instance) in front of the dialog.

Using a CFormView was suggested to me, but will that restrict the dialog to the boundaries of the application?  That is my main dilemma - I need the nonrestricted property of the dialog, to not be stuck inside the main window boundaries, but I also need the other windows to be allowed to come to the front, before the dialog.
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

sorry, should be CWnd::GetDesktopWindow() of course ... :)
applebyAuthor Commented:
Great!  Of course that makes sense, and works wonderfully.  Just one thing - is there a way (there must be) to keep it from adding its own icon to the taskbar when you do it this way?
applebyAuthor Commented:
(out of curiosity, you can still answer that last question, but I don't need to do it so it doesn't matter.)
Hi again,

sorry for long delay, had some free days :)

One way to avoid the icon of the dialog is following:

Create a hidden 'dummy' window and than create your dialog with this dummy as owner, i.e.:

Create an empty dialog resource with style Visible not set and a class for it called CDummyDlg. When creating your dialog do following:

m_pDummy = new CDummyDlg(this);
m_pDummy->Create( CDummyDlg::IDD, GetDesktopWindow() );

m_pDlg = new CMlDlg(this);
m_pDlg->Create/*Hidden*/( CMlDlg::IDD, m_pDummy );

applebyAuthor Commented:
Thanks.  I'll remember that if I need to do it in the future.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.