
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]