ChildFrm.cpp
资源名称:ceditor.rar [点击查看]
上传用户:hgtech
上传日期:2022-06-07
资源大小:4455k
文件大小:3k
源码类别:
词法分析
开发平台:
Visual C++
- // ChildFrm.cpp : implementation of the CChildFrame class
- //
- #include "stdafx.h"
- #include "C_Editor.h"
- #include "BG.h"
- #include "ChildFrm.h"
- #include "SynEditView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CChildFrame
- IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
- BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
- //{{AFX_MSG_MAP(CChildFrame)
- ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CChildFrame construction/destruction
- CChildFrame::CChildFrame()
- {
- // TODO: add member initialization code here
- }
- CChildFrame::~CChildFrame()
- {
- }
- BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- if( !CMDIChildWnd::PreCreateWindow(cs) )
- return FALSE;
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CChildFrame diagnostics
- #ifdef _DEBUG
- void CChildFrame::AssertValid() const
- {
- CMDIChildWnd::AssertValid();
- }
- void CChildFrame::Dump(CDumpContext& dc) const
- {
- CMDIChildWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CChildFrame message handlers
- void CChildFrame::OnFileOpen()
- {
- // TODO: Add your command handler code here
- m_bAutoReturn = AfxGetApp()->GetProfileInt(_T("Editor Settings"), _T("Auto Return"), TRUE);
- CFileDialog fd(TRUE);
- if(fd.DoModal()==IDCANCEL)
- return;
- CC_EditorApp *pApp = (CC_EditorApp *)AfxGetApp();
- pApp->OpenDocumentFile(fd.m_ofn.lpstrFile); //用MFC的方法建立一个新视
- CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
- CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
- CSynEditView *pView = (CSynEditView *)pChild->GetActiveView();
- pView->LoadFile(fd.m_ofn.lpstrFile);
- pView->SetWrapMode
- (m_bAutoReturn==TRUE? CSynEditView::WrapToWindow:CSynEditView::WrapNone);
- }
- BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
- {
- CRect rect;
- GetClientRect(&rect);
- m_wndSplitter.CreateStatic(this,2,1);
- m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(BG),CSize(rect.Width(),1*rect.Height()/3),pContext);
- m_wndSplitter.CreateView(0,0,pContext->m_pNewViewClass,
- CSize(rect.Width(),2*rect.Height()/3),
- pContext
- );
- m_wndSplitter.SetActivePane(0,0);
- return true;
- }
- BOOL CChildFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CMDIFrameWnd* pParentWnd, CCreateContext* pContext)
- {
- // TODO: Add your specialized code here and/or call the base class
- return CMDIChildWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, pContext);
- }