Solved

Cannot Create Empty Document error

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 47
fizzArray2 challenge 1 58
either24  challenge 19 84
Fibonacci challenge 11 82
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 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

20 Experts available now in Live!

Get 1:1 Help Now