Solved

Cannot Create Empty Document error

Posted on 1998-03-11
5
499 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

830 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