[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Failed to create empty document.

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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 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.
Suggested Courses

650 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