📄 editorview.cpp
字号:
// EditorView.cpp : CEditorView 类的实现
//
#include "stdafx.h"
#include "Editor.h"
#include "EditorDoc.h"
#include "EditorView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CEditorView
static UINT WM_FINDREPLACE = ::RegisterWindowMessage(FINDMSGSTRING);
IMPLEMENT_DYNCREATE(CEditorView, CFormView)
BEGIN_MESSAGE_MAP(CEditorView, CFormView)
ON_COMMAND(ID_EDIT_FIND, OnEditFind)
ON_COMMAND(ID_EDIT_REPLACE, OnEditReplace)
ON_REGISTERED_MESSAGE( WM_FINDREPLACE, OnFindReplace )
END_MESSAGE_MAP()
// CEditorView 构造/销毁
CEditorView::CEditorView()
: CFormView(CEditorView::IDD)
{
// TODO: 在此处添加构造代码
m_pfrDlg=NULL;
IsFind=TRUE;
}
CEditorView::~CEditorView()
{
}
void CEditorView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT1, TextEdit);
}
BOOL CEditorView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
// 样式
return CFormView::PreCreateWindow(cs);
}
void CEditorView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
}
// CEditorView 诊断
#ifdef _DEBUG
void CEditorView::AssertValid() const
{
CFormView::AssertValid();
}
void CEditorView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CEditorDoc* CEditorView::GetDocument() const // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEditorDoc)));
return (CEditorDoc*)m_pDocument;
}
#endif //_DEBUG
// CEditorView 消息处理程序
void CEditorView::OnEditFind()
{
// TODO: 在此添加命令处理程序代码
if (m_pfrDlg == NULL)
{
m_pfrDlg = new CFindReplaceDialog();
if(!m_pfrDlg->Create(TRUE, "", "", FR_DOWN, this ))
m_pfrDlg=NULL;
IsFind=TRUE;
}
else
m_pfrDlg->SetActiveWindow();
}
void CEditorView::OnEditReplace()
{
// TODO: 在此添加命令处理程序代码
if (m_pfrDlg == NULL)
{
m_pfrDlg = new CFindReplaceDialog();
if(!m_pfrDlg->Create(FALSE, "","", FR_DOWN, this ))
m_pfrDlg=NULL;
IsFind=FALSE;
}
else
m_pfrDlg->SetActiveWindow();
}
LONG CEditorView::OnFindReplace(WPARAM wParam, LPARAM lParam)
{
CFindReplaceDialog* pDialog = CFindReplaceDialog::GetNotifier(lParam);
if(pDialog != NULL)
{
if (pDialog->IsTerminating())
{
m_pfrDlg = NULL;
}
else if (pDialog->FindNext())
{
OnFindNext(pDialog->GetFindString(),pDialog->SearchDown(),
pDialog->MatchCase());
}
else if (pDialog->ReplaceCurrent())
{
OnReplaceSel(pDialog->GetFindString(),pDialog->SearchDown(),
pDialog->MatchCase(),pDialog->GetReplaceString());
}
else if (pDialog->ReplaceAll())
{
OnReplaceAll(pDialog->GetFindString(), pDialog->GetReplaceString(),
pDialog->MatchCase());
}
}
return 0;
}
void CEditorView::OnReplaceSel(LPCTSTR lpszFind, BOOL bNext, BOOL bCase,LPCTSTR lpszReplace)
{
MessageBox("ReplaceSel");
}
void CEditorView::OnReplaceAll(LPCTSTR lpszFind, LPCTSTR lpszReplace, BOOL bCase)
{
MessageBox("ReplaceAll");
}
void CEditorView::OnFindNext(LPCTSTR lpszFind, BOOL bNext, BOOL bCase)
{
MessageBox("FindNext");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -