Archived

This topic is now archived and is closed to further replies.

[MFC MDI] Is there a way to get rid of the document type dialog?

This topic is 4969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, Is there a way to get rid of the doc type dialog when a user press file new, while there is more than 1 type of document temp? ( and have a few type of document created by default? ) Thanks

Share this post


Link to post
Share on other sites
Yes, there is. You have to override OnFileOpen in your CWinApp-derived class. You can display your own dialog there or do whatever you want to decide which type you want to open.

Then to finally create a new document use the wanted DocTemplate (the templates you used in CWinApp::InitInstance in AddDocTemplate).


Do the following, probably not all of those are needed:


CDocument* pDoc;

pDoc = pDocTemplate->CreateNewDocument();

CFrameWnd* pFrameWnd = pDocTemplate->CreateNewFrame( pDoc, NULL );

pDocTemplate->InitialUpdateFrame( pFrameWnd, pDoc, TRUE );

// not that important

pDoc->SetTitle( "New Document" );

Share this post


Link to post
Share on other sites
Thanks, Endurion.
With your help, now i got it working.

But then one thing i notice, there has no parameter for size of the child window... ?

Thanks again

Share this post


Link to post
Share on other sites
You can control the size of the new view in the views OnInitialUpdate. This also works for every view, regardless of being created new or opened from a file.

Share this post


Link to post
Share on other sites