Solved

Cannot Create Empty Document error

Posted on 1998-03-11
5
505 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adapt this command to show who installed 29 114
ODBC Connection Logging, ADO.NET 6 73
ffmpeg - "rtsp://...... Operation not permitted" 4 92
post4 challenge 28 121
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 …
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Suggested Courses

734 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