kiDDevil
kiDDevil

Reputation: 23

dlg.DoModal() is making the dialog box modal to the application and not to the previous dialogue box

if (IDOK == dlg.DoModal())
    {
        csFile = dlg.GetPathName();
        return (LPCTSTR)csFile;
    }
    return NULL;

I have a desktop application and in this I have a dialog box. When I click on open button in this dialog box another open dialog box should pop up. Once this open dialogue box is displayed I am able to again go to the previous dialogue box and click on open. So second instance of open dialog box is displayed. I can do this many times. The open dialog box is modal to the whole application and not to the previous dialog box. Can anyone help me with this? As per design once open dialog box is displayed nothing else should be active till this is closed.

Upvotes: 0

Views: 1646

Answers (1)

Edward Clements
Edward Clements

Reputation: 5152

The standard wizard-generated constructor for the dialog box contains an optional constructor-parameter where you can specify the parent window:

class CMyOpenDialog : public CDialog
{
// Construction
public:
    CMyOpenDialog(CWnd* pParent = NULL);   // standard constructor
...

When you invoke this second dialog from your dialog, supply the parent, like

CMyOpenDialogdlg(this);

Upvotes: 2

Related Questions