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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
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,


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.