📄 compareview.cpp
字号:
// compareView.cpp : implementation of the CCompareView class
//
#include "stdafx.h"
#include "compare.h"
#include "word.h"
#include "compareDoc.h"
#include "compareView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCompareView
IMPLEMENT_DYNCREATE(CCompareView, CEditView)
BEGIN_MESSAGE_MAP(CCompareView, CEditView)
//{{AFX_MSG_MAP(CCompareView)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_FILE_std_OPEN, OnFILEstdOPEN)
ON_COMMAND(ID_COMP, OnComp)
ON_UPDATE_COMMAND_UI(ID_COMP, OnUpdateComp)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CEditView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CEditView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CEditView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCompareView construction/destruction
CCompareView::CCompareView()
{
// TODO: add construction code here
m_csCompFilename = "";
m_csStdFilename = "";
}
CCompareView::~CCompareView()
{
}
BOOL CCompareView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
BOOL bPreCreated = CEditView::PreCreateWindow(cs);
cs.style &= ~(ES_AUTOHSCROLL|WS_HSCROLL); // Enable word-wrapping
return bPreCreated;
}
/////////////////////////////////////////////////////////////////////////////
// CCompareView drawing
void CCompareView::OnDraw(CDC* pDC)
{
CCompareDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCompareView printing
BOOL CCompareView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default CEditView preparation
return CEditView::OnPreparePrinting(pInfo);
}
void CCompareView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
// Default CEditView begin printing.
CEditView::OnBeginPrinting(pDC, pInfo);
}
void CCompareView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
{
// Default CEditView end printing
CEditView::OnEndPrinting(pDC, pInfo);
}
/////////////////////////////////////////////////////////////////////////////
// CCompareView diagnostics
#ifdef _DEBUG
void CCompareView::AssertValid() const
{
CEditView::AssertValid();
}
void CCompareView::Dump(CDumpContext& dc) const
{
CEditView::Dump(dc);
}
CCompareDoc* CCompareView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCompareDoc)));
return (CCompareDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCompareView message handlers
void CCompareView::OnFileOpen()
{
// TODO: Add your command handler code here
char szFilter[]="All files (*.*)|*.*|Text files(*.txt)|*.txt||";
CFileDialog dlg(true,NULL,NULL,NULL,szFilter);
if(dlg.DoModal() == IDOK)
{
m_csCompPathname = dlg.GetPathName();
m_csCompFilename = dlg.GetFileTitle();
}
}
void CCompareView::OnFILEstdOPEN()
{
// TODO: Add your command handler code here
char szFilter[]="All files (*.*)|*.*|Text files(*.txt)|*.txt||";
CFileDialog dlg(true,NULL,NULL,NULL,szFilter);
if(dlg.DoModal() == IDOK)
{
m_csStdFilename = dlg.GetFileTitle();
m_csStdPathname = dlg.GetPathName();
}
}
void CCompareView::OnComp()
{
// TODO: Add your command handler code here
// AfxMessageBox("done!");
CString cspathname;
cspathname = m_csCompFilename + " " + m_csStdFilename;
SetCurrentDirectory(m_curDir);
CreateDirectory(cspathname,NULL);
CString cspath = m_curDir + CString("\\") + cspathname;
SetCurrentDirectory(cspath);
Compare((LPCTSTR)m_csCompPathname, (LPCTSTR)m_csStdPathname, (LPCTSTR)m_csCompFilename, (LPCTSTR)m_csStdFilename, m_curDir);
GetDocument()->OnOpenDocument("result.txt");
}
void CCompareView::OnUpdateComp(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if (m_csStdFilename.IsEmpty() || m_csCompFilename.IsEmpty())
pCmdUI->Enable(FALSE);
else
pCmdUI->Enable(TRUE);
}
void CCompareView::OnInitialUpdate()
{
CEditView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
GetCurrentDirectory(MAX_PATH,m_curDir);
//if ()
//CreateDirectory()
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -