Modeless dialog in a MFC document/view application 
Author Message
 Modeless dialog in a MFC document/view application

Hi all:
    I found it difficult to display a modeless dialog in a MFC document/view
application. I have tried to change the code as following, but the dialog
doesn't show at all.

void CTestApp::OnAppAbout()
{
 CAboutDlg aboutDlg;

 aboutDlg.Create(IDD_ABOUTBOX, NULL);
 aboutDlg.ShowWindow(WS_VISIBLE);
// aboutDlg.DoModal(); I remark this line because I want this dialog to be
display modeless

Quote:
}

Can any one tell me why this can not work?

Thanks in advance
Kevin



Tue, 06 Jan 2004 22:01:08 GMT  
 Modeless dialog in a MFC document/view application
try :

aboutDlg.ShowWindow(SW_SHOW);

or

aboutDlg.ModifyStyle(0, WS_VISIBLE);



Quote:
> Hi all:
>     I found it difficult to display a modeless dialog in a MFC
document/view
> application. I have tried to change the code as following, but the dialog
> doesn't show at all.

> void CTestApp::OnAppAbout()
> {
>  CAboutDlg aboutDlg;

>  aboutDlg.Create(IDD_ABOUTBOX, NULL);
>  aboutDlg.ShowWindow(WS_VISIBLE);
> // aboutDlg.DoModal(); I remark this line because I want this dialog to be
> display modeless
> }

> Can any one tell me why this can not work?

> Thanks in advance
> Kevin



Tue, 06 Jan 2004 23:26:41 GMT  
 Modeless dialog in a MFC document/view application
Hi, Kevin!

Other potential sources of failure aside, your CAboutDlg is instantiated as a local variable. It
will be destroyed as soon as the function exits -- which is just about as soon as it is shown.

Jeff...
--
Please post all follow-ups to the newsgroup only.

Quote:

> Hi all:
>     I found it difficult to display a modeless dialog in a MFC document/view
> application. I have tried to change the code as following, but the dialog
> doesn't show at all.

> void CTestApp::OnAppAbout()
> {
>  CAboutDlg aboutDlg;

>  aboutDlg.Create(IDD_ABOUTBOX, NULL);
>  aboutDlg.ShowWindow(WS_VISIBLE);
> // aboutDlg.DoModal(); I remark this line because I want this dialog to be
> display modeless
> }

> Can any one tell me why this can not work?

> Thanks in advance
> Kevin



Wed, 07 Jan 2004 06:04:47 GMT  
 Modeless dialog in a MFC document/view application

Quote:

> Hi all:
>     I found it difficult to display a modeless dialog in a MFC document/view
> application. I have tried to change the code as following, but the dialog
> doesn't show at all.

> void CTestApp::OnAppAbout()
> {
>  CAboutDlg aboutDlg;

>  aboutDlg.Create(IDD_ABOUTBOX, NULL);
>  aboutDlg.ShowWindow(WS_VISIBLE);
> // aboutDlg.DoModal(); I remark this line because I want this dialog to be
> display modeless
> }

> Can any one tell me why this can not work?

> Thanks in advance
> Kevin

Modeless dialogs stay around a lot longer than during one function
call.  Except yours, which is destroyed almost immediately because
aboutDlg goes out of scope when the function returns.  Use a member
variable instead:

 m_pAboutDlg = new CAboutDlg;

Then you'll need code somewhere else to ->DestroyWindow and delete
m_pAboutDlg.

--
Scott McPhillips [VC++ MVP]



Wed, 07 Jan 2004 06:56:22 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Showing a modeless progress dialog while opening document with MFC

2. Modeless dialog to be main window of MFC Application

3. Modeless Dialog box in a Modal Dialog Application...

4. How to Access View methods from Document in MFC DOC/VIEW

5. Non MFC modal dialogs in an MFC application - Dialog Message problem

6. create a scroll view within a modeless dialog

7. Getting pointer to view in modeless dialog box

8. create a scroll view within a modeless dialog

9. Error accessing my Modeless Dialog from 3rd party application

10. How To Close Modeless Dialogs in an MDI Application

11. Kill application from modeless dialog

12. Problem with putting modeless dialog in SDI application

 

 
Powered by phpBB® Forum Software