Solved

Cannot Create Empty Document error

Posted on 1998-03-11
5
477 Views
Last Modified: 2013-11-20
What are the causes of a "Cannot Create Empty Document" error and how do I fix it?

I have run it through the debugger and stepped through the system code; here is the line that it is breaking on:

if (! (AfxGetApp()-> OnCmdMsg (ID_FILE_NEW, 0,  NULL, NULL))
    OnFileNew()

AfxGetApp()->OnCmdMsg is returning 1. Presumably it should be returning 0. I have had no experience with writing or debugging low-level system code, so I have no idea what is going on. This application is breaking on a Win95 machine. It runs fine on a WinNT machine. I am coding in Visual C++ 5.0.

Thanks.
0
Comment
Question by:horn
  • 3
  • 2
5 Comments
 

Author Comment

by:horn
ID: 1316920
Edited text of question
0
 
LVL 11

Accepted Solution

by:
mikeblas earned 50 total points
ID: 1316921
This isn't low-level systems code.

The error means that MFC trie to create a new, empty CDocument instance and failed, or that MFC failed while trying to create a CView to associate with that new document, or MFC encountered a failure while associating the document and the view with an already-created frame window.

You should put a breakpoint on the message handler, which is CWinApp::OnFileNew(), and start tracing through the code.  You'll find that one of several things is happening:

1) Your View class requires a window that isn't registered and can't be created. For example, you're using a CFormView with a rich edit control on it, but you've never called AfxInitRichEdit().  Or, you're using a CFormView that has an OLE control but that OLE control isn't creating for some reason.

2) The constructor for your document is throwing an exception.

3) The frame window in your application can't be created.

4) The constructor for your view class is throwing an exception.

5) You never registered any doc templates.

6) You've supplied your own doc template class, and screwed up overriding the creation functions.

_Any_ of the above causes will have MFC write some TRACE output to the debugger. Diagnosing the problem is usually a matter of reading that diagnostic output and fixing the cause.

You can search through MFC's source code for the string AFX_IDP_FAILED_TO_CREATE_DOC to see the exact places where MFC posts that error message.

.B ekiM


0
 

Author Comment

by:horn
ID: 1316922
I fixed it; the constructor was throwing an exception, but I do not know why. My code runs on NT machines but not Win95 machines. Thank you for the information.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1316923
For more information on exceptions, read the SDK documentation.  For hints on debugging exceptions, read the articles I wrote for VC++ Developer at http://www.pinpub.com/vcd/home.htm.

.B ekiM
0
 

Author Comment

by:horn
ID: 1316924
I'll check it out. Thanks, mikeblas.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expand LInux Boot partition remotly 3 86
only14 challenge 19 68
post4 challenge 28 93
ASP.NET C# MessageBox.Show Showing a modal dialog box or form when the application ... 2 104
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now