The second dialog is modal with the first.
Main Topics
Browse All TopicsI would like my dialog box to display another dialog when a message is received. What is the effect of the following code on the calling thread? Is it allowed? Will it kill the message handling of the thread managing the MyDlgClass dialog? Should I have bidirectional messages instead (and manage the first dialog with CreateDialog)?
void MyShowDialog()
{
.
.
DialogBox(hInstance, "MyDlgClass", NULL, MyDlgProc);
.
.
}
INT_PTR CALLBACK MyDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
.
case WM_INITDIALOG:
DialogBox(hInstance, "MyOtherDlgClass", NULL, MyOtherDlgProc);
break;
.
.
}
Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
It's OK, you can do this. Internally Windows creates message loop for each modal dialog. When you call second modal dialog, Windows disables parent dialog, but it's message loop is active, so parent dialog can redraw itself. Child dialog runs with it's own message loop, when it is closed, parent is activated.
No, this is the same thread, but another message loop. When your program runs, MyDloProc function instance is loaded to the stack. If this instance is handling WM_INITDIALOG, another dialog is opened. This MyDlgProc instance remains on the stack waiting for child dialog to be closed. However, message loop continues to run, and this dialog handles other messages, for example, WM_PAINT. When dialog is redrawn, another instance of MyDlgProc is loaded onto the stack, handles WM_PAINT message and unloaded.
This looks tricky because we don'r see the whole picture, we see only our message handlers called from somewhere. Adding some TRACE messages allows to understand this better.
I understand; thank you very much! I awarded you the points. But there is still a small point I would like to have info on. Is there something special I must do if I "block" the handler for WM_INITDIALOG? As I see it, since the first dialog is not initialized (the handler did not return), the dialog will not be shown... Or is it simply irrelevent since the return value of WM_INITDIALOG only affects the keyboard focus, which will be disabled as long as the second modal dialog will be visible?
Thanks again.
Business Accounts
Answer for Membership
by: _Rob_Posted on 2003-08-04 at 06:28:47ID: 9069906
It looks like the second dialog is going to be modal with the first. Is that what you want? Or should the user be able to work with both dialogs at once?
/rob