main dialog window is blocked by second dialog window 
Author Message
 main dialog window is blocked by second dialog window

Hi!

  I created a dialog with the MFC AppWizard. The
main ".cpp" created the first dialog like this :

/**************************/
 CFirstDlg first;
 m_pMainWnd = &first;
 int nResponse = first.DoModal();
/**************************/

  Now in the "OnInitDialog()" function of "first"
I added another dialog ("second") in this fashion :

/*********************************/
 second.Create(IDD_GRAPH, this);
 second.ShowWindow(SW_SHOW);
/*********************************/

The declaration "CSecondDlg second;" is included
in the header file.
  But how come the second dialog covers the first
one when the program starts? And even after I focus
on the first dialog and move it around, still the second
dialog is in the foreground.
  How can I change this, so that the dialog on which
I clicked the mouse on steps into the foreground and
appears above the other?

  Thanks and regards,

                       Oliver



Tue, 01 Mar 2005 13:05:20 GMT  
 main dialog window is blocked by second dialog window
In the call to Create (2nd dialog), instead of passing "this", pass the
desktop window as the 2nd parameter.
For more info, see this article :-
http://www.codeproject.com/dialog/gettingmodeless.asp

Regards,
Nish


Quote:
> Hi!

>   I created a dialog with the MFC AppWizard. The
> main ".cpp" created the first dialog like this :

> /**************************/
>  CFirstDlg first;
>  m_pMainWnd = &first;
>  int nResponse = first.DoModal();
> /**************************/

>   Now in the "OnInitDialog()" function of "first"
> I added another dialog ("second") in this fashion :

> /*********************************/
>  second.Create(IDD_GRAPH, this);
>  second.ShowWindow(SW_SHOW);
> /*********************************/

> The declaration "CSecondDlg second;" is included
> in the header file.
>   But how come the second dialog covers the first
> one when the program starts? And even after I focus
> on the first dialog and move it around, still the second
> dialog is in the foreground.
>   How can I change this, so that the dialog on which
> I clicked the mouse on steps into the foreground and
> appears above the other?

>   Thanks and regards,

>                        Oliver



Tue, 01 Mar 2005 14:02:53 GMT  
 main dialog window is blocked by second dialog window
First, if you create a Modal dialog then it will
retain the focus
until you close it by clicking Cancel, Ok or exit
in some other
way.  So you need to create a 'Modeless Dialog" if
you want to
have both at the same time.  There are tutorials
on the subject
(I think there is one in MSDN: Creating Modeless
Dialogs???)

BUT...
This sounds like a odd design.  Normally, you
would create
the main dialog and then create the second dialog
when the
user clicks on a button to do something that isn't
available
on the main dialog.

Good Luck.
RickL



| Hi!
|
|   I created a dialog with the MFC AppWizard. The
| main ".cpp" created the first dialog like this :
|
| /**************************/
|  CFirstDlg first;
|  m_pMainWnd = &first;
|  int nResponse = first.DoModal();
| /**************************/
|
|   Now in the "OnInitDialog()" function of
"first"
| I added another dialog ("second") in this
fashion :
|
| /*********************************/
|  second.Create(IDD_GRAPH, this);
|  second.ShowWindow(SW_SHOW);
| /*********************************/
|
| The declaration "CSecondDlg second;" is included
| in the header file.
|   But how come the second dialog covers the
first
| one when the program starts? And even after I
focus
| on the first dialog and move it around, still
the second
| dialog is in the foreground.
|   How can I change this, so that the dialog on
which
| I clicked the mouse on steps into the foreground
and
| appears above the other?
|
|   Thanks and regards,
|
|                        Oliver
|
|
|
|



Tue, 01 Mar 2005 14:14:32 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Dialog box as a main window in windows 95, using Win32 SDK only (MSVC 5.00)

2. Display a dialog window before the main Window

3. Dialog owned by main window not hidden when main minimized

4. Opening a second dialog window question

5. problem painting second dialog window

6. How to change on runtime the caption of a C++ dialog app main window

7. How to change on runtime the caption of a C++ dialog app main window

8. Application's main window a dialog?

9. Dialog as main windows under SDK (not MFC)

10. Help: dialog as main window

11. displaying dialog box with my main window..

12. Dialog Box as Main Window/No debugger /4.0

 

 
Powered by phpBB® Forum Software