?
Solved

OpenDocumentFile(NULL) keeps crashing!

Posted on 2005-05-16
6
Medium Priority
?
1,012 Views
Last Modified: 2013-11-20
Hi,

I just want to open a new instance of my document class! But everytime I try OpenDocumentFile(NULL);, I get a big crash because that function is trying to parse the input of the function, accessing element [0] when there is none!

Where should I call OpenDocumentFile(NULL) from to create a new instance of the document? Right now I am calling it from an instance of a CMDIChildWnd window. This window has a list ctrl in it, when I double click an item, I am calling OpenDocumentFile().

Is that wrong? What should I do?

Also, is it possible to pass some initialization parameters to the document class? Otherwise I will have to have the document class searching around for its data!


Thanks!
0
Comment
Question by:BazookaJoeZone
  • 3
  • 3
6 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 14014263
Try with:
theApp.OnFileNew();
0
 
LVL 3

Author Comment

by:BazookaJoeZone
ID: 14014750
That function is protected, I added a public override to it but it is just an empty function body that does nothing when called.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 14014804
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 3

Author Comment

by:BazookaJoeZone
ID: 14015257
Thanks jaime. The second article is what I needed, it works well.

For the second part of my question, have you found any good methods of passing a struct for example to the new document coming into being while calling OpenDocumentFile()?
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 14015308
OpenDocumentFile() returns you a pointer to a generic CDocument
You just have to cast it to your document class and call some initialization method for it, something like this:

    CMyApp* pApp = (CMyApp*)AfxGetApp();
    CMyDocClass *pDoc =(CMyDocClass *) pApp->m_pDocTemplate->OpenDocumentFile(NULL);
    pDoc->YourInitializeFunction(some_struct_pointer);
0
 
LVL 3

Author Comment

by:BazookaJoeZone
ID: 14015323
Thanks a lot jaime, you've been really helpful.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

862 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