Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Cannot Create Empty Document error

Posted on 1998-03-11
5
Medium Priority
?
533 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 150 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

715 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