Solved

Failed to create empty document.

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

762 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

18 Experts available now in Live!

Get 1:1 Help Now