Solved

Failed to create empty document.

Posted on 1998-08-31
5
588 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
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 10 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

920 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

15 Experts available now in Live!

Get 1:1 Help Now