[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Failed to create empty document.

Posted on 1998-08-31
5
Medium Priority
?
627 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 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

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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

873 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