How to run one dialog from another (WinAPI)?

Started by
3 comments, last by Emmanuel Deloget 18 years, 1 month ago
I create one dialog: DialogBox(hInstance, MAKEINTRESOURCE(IDD_PROJECT_SETTINGS), hWnd, Project_Settings_Proc); Then I try create some child dialog, even like MessageBox, but it is shown as inactive. How to make it active and able to get some actions?
VATCHENKO.COM
Advertisement
The DialogBox() function creates a modal dialog, which means it does not return control to the processing thread until it's done it's own little thing. If you're trying to create your other child windows beyond the call to the DialogBox() function, then you'll have troubles. So, like...

DialogBox();

CreateWindow(blahblah);

In the above case, CreateWindow() won't be called until after the dialog box created by the DialogBox() function has been destroyed. But even if you were trying to create other windows from within the message proc of the DialogBox(), they still won't show, I think, because the thing is modal.

In other words... Try doing a modeless dialog box using the CreateDialog() function instead.
I mean my dialog is working, and the second dialog is shown too, but it's inactive! CreateDialog() did not help me: MessageBox(hDlg, "123", 0, MB_OK); in DialogProc creates a message box where I see OK button but can't press it!
VATCHENKO.COM
Omega147 has already answered your question, the fact is DialogBox () invoke a modal dialog that (in general) take over control of the main window and doesn't return until you call EndDialog (). What you want is probably a modeless dialog by CreateDialog ().

An example for this is you can only interact with a message box one at a time, which is a modal dialog.
--> The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones <--
Quote:Original post by Anton Vatchenko
I mean my dialog is working, and the second dialog is shown too, but it's inactive! CreateDialog() did not help me: MessageBox(hDlg, "123", 0, MB_OK); in DialogProc creates a message box where I see OK button but can't press it!


Can you show us your code please?

[edit: core != code; sorry for the typo]

Regards,

[Edited by - Emmanuel Deloget on March 4, 2006 5:06:16 PM]

This topic is closed to new replies.

Advertisement