0
votes

I want to pop-up a dialog for creating a new file in MFC to collect detail information for a document like Photoshop. (e.g. width, height, depth .)

I found two answers from stackoverflow.

Configuring new document in MFC

MFC, File New with dialog to prompt for paramters and multiple Doc Types?

I want to try the formal one, but I cannot understand the suggestion:

just post a custom message/command to the main frame. Then add a handler that will react by the sequence pop up GUI/update doc/update views. That way, the main frame will be displayed before the GUI is popped up and your user will be happier.

Can anyone explain in detail?

Thanks in advance.

1

1 Answers

0
votes

I'm not very sure about the answer you quoted, what I normally do is to pop up the dialog box to collect the new file information in the OnNewDocument() member function -- as the quoted question mentions, it's a bit ugly to put in a UI in the document class, but it works...

BOOL CMyDoc::OnNewDocument()
{   if (!CDocument::OnNewDocument()) // substitute CDocument with your document base class
        return FALSE;
    CFileNewInfo dlg(AfxGetApp()->GetMainWnd());
    // ... set up dialog member variables
    if (dlg.DoModal() != IDOK)
        return FALSE;
    // ... retrieve dialog member variables and update your document appropriately
    return TRUE;
}