Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Opening/Creating documents from code

Posted on 2003-03-23
2
Medium Priority
?
352 Views
Last Modified: 2013-11-20
Hi

I have three MultiDocTemplates in my app. I want to be able to
create new and open existing files from my code. I find the
correct template and have tried a number of ways such as

COleDocument* pDoc = pDocTemplate->CreateNewDocument();

or

COleDocument* pDoc = pDocTemplate->CreateNewDocument();
CChildFrame* pChild = pDocTemplate->CreateNewFrame(pDoc, NULL);

pChild->ShowWindow(m_nCmdShow);

here I get a blank childframe with no title.

or because I am using active documents

COleDocument* pDoc = pDocTemplate->CreateNewDocument();
CChildFrame* pChild = pDocTemplate->CreateOleFrame((CMainFrame*)AfxGetApp()->GetMainWnd(),pDoc,TRUE);

pChild->ShowWindow(m_nCmdShow);

This one cause the program to crash!

Any help much appreciated, must work for Active Documents

Thanks
Mark
0
Comment
Question by:mjwilliamson
2 Comments
 
LVL 1

Accepted Solution

by:
keitha1 earned 300 total points
ID: 8191832
CMyDoc* pDoc = (CMyDoc*) m_pDocTemplate->CreateNewDocument ();
ASSERT (pDoc);

pDoc->SetTitle (filename);

CFrameWnd* pFrame = m_pDocTemplate->CreateNewFrame (pDoc, NULL);
ASSERT (pFrame);
m_pDocTemplate->InitialUpdateFrame (pFrame, pDoc);

// Optionally you can trigger an Update event
pDoc->UpdateAllViews (NULL, FILE_LOADED_HINT);


I hope this helps some.
0
 
LVL 2

Expert Comment

by:manojbkumar
ID: 8192860
COleDocument* pDoc = pDocTemplate->OpenDocumentFile(NULL);
ASSERT(pDoc);
pDoc->SetTitle("Hai"/*Document title*/);
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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 …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month11 days, 4 hours left to enroll

571 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