简体   繁体   中英

Dialog based New file in MFC

I want to pop-up a dialog for creating a new file in MFC to collect detail information for a document like Photoshop. (eg 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.

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM