views:

476

answers:

5

Can someone say me how I could do a No Modal Dialog in MFC's Visual c++ 6.0 for show it? I wrote this,

CDialog dialog; if (dialog.init(initialization values...)) dialog.DoModal();

But it blocks my application for show the dialog. I dont know if exists any method or other way to do.

Thanks

+2  A: 

You need to call CDialog::Create instead. You will need to call DestroyWindow when you are finished with the dialog. You might also need to pass dialog messages onto the object but I can't remember if MFC handles this for you or not.

Rob
+3  A: 

Use CDialog::Create and then use CDialog::ShowWindow. You now have a modeless dialog box.

Goz
+2  A: 

DoModal is blocking. You have to create your dialog on the heap or make it a member of your class (this is important), call Create then call ShowWindow.

Nikola Smiljanić
+2  A: 
/* CChildDialog class is inherited from CDialog */
CChildDialog *m_pDialog = NULL;

// Invoking the Dialog
m_pDialog = new CChildDialog();

if (pDialog != NULL)
{
      BOOL ret = m_pDialog->Create(IDD_CHILDDIALOG, this);

      if (!ret)   //Create failed.
         AfxMessageBox(_T("Error creating Dialog"));

      m_pDialog->ShowWindow(SW_SHOW);
}

// Delete the dialog once done
delete m_pDialog;
Ramakrishna
A: 

alternatively, if you want to be independet of microshit : http://msdn.microsoft.com/en-us/library/ms645434%28VS.85%29.aspx