?
Solved

Failed to create empty document.

Posted on 1998-08-31
5
Medium Priority
?
603 Views
Last Modified: 2008-02-01
Does someone have an answer why in some NT4 or W95 configurations I'm getting the error message "Failed to create empty document" when I'm trying to run my application that was made by VC++4.0.
Thanks.
m3.
0
Comment
Question by:m3
[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
5 Comments
 

Expert Comment

by:t004024
ID: 1171751
I usually get this when I return FALSE from either one of my OnCreate of View or the LoadFrame of the Frame, i.e., when I do not want to create a new document and cacel the creation.
0
 
LVL 3

Expert Comment

by:danny_pav
ID: 1171752
This happens when OnNewDocument returns FALSE;
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 20 total points
ID: 1171753
I've searched the MFC source, there are several possible reasons:

1. You didn't add a document template to your WinApp (OnFileNew causes this error message) - this seems the most likely cause to me

2. CDocTemplate::CreateNewDocument returns NULL.   This can happen because you've not overriden it properly or deserializing (load from a file) messes up.

3. CreateNewFrame returns NULL (in OpenDocumentFile) this will usually again be for the same types of reasons as #2

4. OpenDocumentFile or CreateNewFrame fail in an MDI app.  Same kind of reasons as number #1


By far the most likely reason is you simply haven't done AddDocTemplate in the initialization of your app.  The sample code that does this an MDI app is

(begin quote)
BOOL CMyApp::InitInstance()
{
   // ...
   // The following code is produced by AppWizard when you
   // choose the MDI (multiple document interface) option.
   CMultiDocTemplate* pDocTemplate;
   pDocTemplate = new CMultiDocTemplate(
      IDR_MYTYPE,
      RUNTIME_CLASS(CMyDoc),
      RUNTIME_CLASS(CMDIChildWnd),        // standard MDI child frame
      RUNTIME_CLASS(CMyView));
   AddDocTemplate(pDocTemplate);
     // ...
}

(end quote)

I figure if this really is intermittent, you're not doing the above quite right.  Check the IDR_MYTYPE (or whatever your version is called) resource (especially the string resource) _really_carefully_
0
 

Author Comment

by:m3
ID: 1171754
I don't think that it has something to do with my Intistance, because it runs on 90% of machines without any problem, but only with some specific configurations it does not work. For example it was not working on a NT4 machine but after formatting its hard drive it started working!!
I don't really understand.
m3.
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1171755
You probably have an uninitialized variable and are returning that.  Therefore what works and doesn't probably depends on what happens to be in that variable's RAM (left over from what was there before).

Compile in release mode and highest warning level.  This may tell you which variable.  Otherwise you'll have to step thru the debugger in all cases.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

770 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