?? lsingledoctemplate.cpp
字號:
// LSingleDocTemplate.cpp: implementation of the LSingleDocTemplate class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "a1.h"
#include "LSingleDocTemplate.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
LSingleDocTemplate::LSingleDocTemplate(UINT nIDResource, CRuntimeClass* pDocClass,
CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass): CSingleDocTemplate(nIDResource, pDocClass,
pFrameClass, pViewClass)
{
m_wndparent=NULL;
m_frame=NULL;
}
LSingleDocTemplate::~LSingleDocTemplate()
{
}
CFrameWnd* LSingleDocTemplate::CreateNewFrame(CDocument *pDoc, CFrameWnd *pOther)
{
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)
{
TRACE0("Error: you must override CDocTemplate::CreateNewFrame.\n");
ASSERT(FALSE);
return NULL;
}
CFrameWnd* pFrame = (CFrameWnd*)m_pFrameClass->CreateObject();
if (pFrame == NULL)
{
TRACE1("Warning: Dynamic create of frame %hs failed.\n",
m_pFrameClass->m_lpszClassName);
return NULL;
}
ASSERT_KINDOF(CFrameWnd, pFrame);
if (context.m_pNewViewClass == NULL)
TRACE0("Warning: creating frame with no default view.\n");
// create new from resource
if (!pFrame->LoadFrame(m_nIDResource,
WS_OVERLAPPEDWINDOW|FWS_ADDTOTITLE ,//| , // default frame styles
m_wndparent, &context))//
{
TRACE0("Warning: CDocTemplate couldn't create a frame.\n");
// frame will be deleted in PostNcDestroy cleanup
return NULL;
}
this->m_frame=(CMyFrame*)pFrame;
if(m_wndparent!=NULL)
{
ASSERT_KINDOF(CWnd,m_wndparent);
CRect rect;
m_wndparent->GetWindowRect(rect);
m_frame->MoveWindow(&rect);
}
// it worked !
return pFrame;
}
void LSingleDocTemplate::SetFrameParent(CWnd *parent)
{
this->m_wndparent=parent;
}
CMyFrame* LSingleDocTemplate::GetMyFrame() const
{
ASSERT(m_frame!=NULL);
ASSERT_KINDOF(CMyFrame,m_frame);
return this->m_frame;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -