Vovka1960

Hi again!

I have some problem with creating modeless dialog windows. To decribe situation I'm going to show you 2 examples:

1. I have 3 modeless dialog windows (the main and 2 additional). This time I'm opening all of them in WinApp::InitInstance procedure. And in this case all works as I want: if I click on any of all 3 windows - the window gets the focus, moving up over other two other dialogs. That is my aim.

2. All the same - 3 modeless dialogs (absolutely the same) and the same procedures for creating them. But this time I have opened only the main dialog in WinApp::InitInstance. Two additional dialogs are opening by the commands in the main dialog. And in this case I have the problem. After opening any of the additional dialogs the main dialog goes down under the additional. Even if it has the focus!

So - this is the question. What is the difference between opening modeless dialogs in WinApp::InitInstance and opening them later (from ON_COMMAND procedures - for ex. from menu commands) What have I to do with main dialog. I want it to go up while getting focus! But not remaining under the additional dialogs!

Some comments: all of the dialog windows have these (some of all) constructing modes:

3D look = true
border = Resizing
style = Popup
window edge = true
topmost = false
system modal = false
Visible = true

most of others are false



Re: Visual C++ General Dialogs: modalities & etc.

Paul Marriott

It will depend on who is the parent for the dialogs you are creating.

If you are creating in the WinApp:: etc startup is the parent the main window

If you are creating in ON_COMMAND, then what is the parent - is it the main window or is it the dialog creating another dialog

When the second and third dialogs are manually created, is it possible to click on and use the first dialog - if not then it sounds like they are being launched as modal dialogs or the first dialog is using EnableWindow (hWnd,FALSE) to disable it.





Re: Visual C++ General Dialogs: modalities & etc.

crescens2k

It is possible that you are creating the dialog incorrectly.

The method of creating a dialog is as follows.

CDialog* pMyDialog = new CDialog();

pMyDialog->Create(IDD_MYRESOURCE, this);

If that is the same way you are doing it, then you should post your code, otherwise all we can do is speculate.






Re: Visual C++ General Dialogs: modalities & etc.

Vovka1960

Thank you for your answers. May be you are both correct and I'm creating dialogs incorrectly. Unfortuantely I have a little expirience in Visual platform (all my life I wrote on embedded C, C++).

So, this is the code, that I use for creating dialogs. I didn't use 'parent' reference while calling CDialog constructor & 'Create' procedure, because I want all my dialogs to be equitable. May be I'm wrong and this is not the correct way. The Idea was that I have the main dialog, through which user can control the situation (globally). Besides he can call additional dialogs to get more detailed information about processes (with the elements of step-by-step control). In any time user can return to main dialog (not closing the additional) and send global control commands to sistem.

So, here it is:

myApp::InitInstance() -- main dialog

m_pMainWnd = new WinRootDialog (NULL);
m_pMainWnd->Create(WinRootDialog::IDD);
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();

I'm NOT creating any other main windows - only the root dialog.

WinRootDialog:SurprisenCommand() -- additional dialogs (from one to six)

dlg = new CWinVesiDlg(NULL);
dlg->Create(CWinVesiDlg::IDD);
dlg->ShowWindow(SW_SHOW);
dlg->UpdateWindow();

That is all. CWinVesiDlg & WinRootDialog are both inherited directly from CDialog and override only onSizing & onPaint procedures.

Thank you for your attention to my problem.




Re: Visual C++ General Dialogs: modalities & etc.

Vovka1960

Here is some additional info: I tried to check parent info for the root and additional dialogs (calling GetParent procedure).

In my case for main dialog I got NULL and for additional dialogs I got the reference to root dialog(!). But I did NOT use this reference neither in constructor nor in Create procedure.

In additional - I check parent info in the case when I open the additional dialogs in myApp::InitInstance. Parent info for both dialogs was NULL! What can I say

And again - for additional. I tried to set parent info for additional dialogs, using dlg->SetParent(NULL). Then - after calling GetParent() - again I got the reference to root dialog,

A-ha!!!
I found some mistake in my first explanation. In the first case, when I create all dialogs in myApp::InitInstance(), I call the procedures for creating additional dialogs after calling constructor for root dialog, BUT BEFORE calling its 'Create' procedure. If I call these procedures AFTER calling 'Create' - I have the same picture - as if I call additional dialogs in OnCommand() procedures.

So - It seems to me, that if I put NULL reference for parent when creating Dialogs, it use m_pMainWnd instead of NULL. But it checks the contents of CWnd class. And if it was not created - exception occurs and dialog gets the NULL for parent ref.

But if I was right - this did not helps me... How can I create 3-5 single-level dialogs and solve my problem