-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyEditorDocTemplate.cpp
More file actions
69 lines (55 loc) · 1.91 KB
/
PyEditorDocTemplate.cpp
File metadata and controls
69 lines (55 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "stdafx.h"
#include "PyEditorDocTemplate.h"
#include <EAF\EAFUtilities.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//////////////////////////////// Macros / Defines /////////////////////////////
#ifdef _DEBUG
#define new DEBUG_NEW
#endif #ifdef _DEBUG
//////////////////////////////// Implementation ///////////////////////////////
CPyEditorDocTemplate::CPyEditorDocTemplate(UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass) :
CMultiDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass)
{
}
CFrameWnd* CPyEditorDocTemplate::CreateNewFrame(CDocument* pDoc, CFrameWnd* pOther)
{
//Validate our parameters
if (pDoc != NULL)
ASSERT_VALID(pDoc);
// create a frame wired to the specified document
ASSERT(m_nIDResource != 0); // must have a resource ID to load from
CCreateContext context;
context.m_pCurrentFrame = pOther;
context.m_pCurrentDoc = pDoc;
context.m_pNewViewClass = m_pViewClass;
context.m_pNewDocTemplate = this;
if (m_pFrameClass == NULL)
{
ASSERT(FALSE);
return NULL;
}
CFrameWnd* pFrame = static_cast<CFrameWnd*>(m_pFrameClass->CreateObject());
if (pFrame == NULL)
{
return NULL;
}
ASSERT_KINDOF(CFrameWnd, pFrame);
//create new from resource
if (!pFrame->LoadFrame(m_nIDResource,
WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, //default frame styles
EAFGetMainFrame(), &context)) //This is the critical change compared to CMultiDocTemplate::CreateNewFrame where we pass "m_pFrameWnd" instead of NULL
{
//frame will be deleted in PostNcDestroy cleanup
return NULL;
}
//it worked !
return pFrame;
}
CDocument* CPyEditorDocTemplate::OpenDocumentFile(LPCTSTR lpszPathName, BOOL bMakeVisible)
{
return __super::OpenDocumentFile(lpszPathName, FALSE/*dont add to MRU*/, bMakeVisible);
}