Microsoft KB Archive/121321

= DOC:CDocTemplate::CreateNewFrame Won't Make New CDocument =

Article ID: 121321

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 1.0 Professional Edition

 Microsoft Visual C++ 1.5 Professional Edition

 Microsoft Visual C++ 1.51

 Microsoft Visual C++ 1.0 Professional Edition</li></ul>

 Microsoft Visual C++ 2.0 Professional Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q121321

<div class="summary_section">

SUMMARY
The Help File documentation for CDocTemplate::CreateNewFrame says: <pre class="fixed_text">  If the pDoc parameter is NULL, a new document will be created if the appropriate runtime class is available; otherwise the new view will be associated with the ... This is not correct. Calling CreateNewFrame with a NULL pDoc parameter actually results in an assertion failure on the pDoc pointer and a TRACE statement in your output or debug window stating the following:

ASSERT_VALID fails with NULL pointer.

The reason for this is that CreateNewFrame is not the appropriate function to call when you don't have a pre-constructed CDocument-derived object. The function to call is CMultiDocTemplate's or CSingleDocTemplate's OpenDocumentFile. The OpenDocumentFile function creates a new CDocument object by using CreateNewDocument.

<div class="moreinformation_section">

MORE INFORMATION
CMultiDocTemplate:: and CSingleDocTemplate::OpenDocumentFile both create a new document if the pointer argument passed to them is NULL. To get a pointer to the appropriate document template that you can use when calling OpenDocumentFile, please see the following article in the Microsoft Knowledge Base:

106455 Acquiring a List of All CDocument Objects

This article contains sample code you can use to traverse the list of available document templates.

This problem was fixed in Microsoft Visual C++, 32-bit Edition, version 4.0.

Additional query words: pDoc ASSERT_VALID OpenDocumentFile 1.00 1.50 2.00 2.10 2.50 2.51 3.00 4.00

Keywords: kbdocfix KB121321

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.