📄 myeditctrl.cpp
字号:
// MyEditCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "C_minus.h"
#include "MyEditCtrl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyEditCtrl
CMyEditCtrl::CMyEditCtrl()
{
}
CMyEditCtrl::~CMyEditCtrl()
{
}
BEGIN_MESSAGE_MAP(CMyEditCtrl, CRichEditCtrl)
//{{AFX_MSG_MAP(CMyEditCtrl)
// NOTE - the ClassWizard will add and remove mapping macros here.
ON_WM_GETDLGCODE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyEditCtrl message handlers
UINT CMyEditCtrl::OnGetDlgCode()
{
return DLGC_WANTALLKEYS; // 让CMyEditCtrl接受TAB键
}
void CMyEditCtrl::SetFormatRange(int nStart, int nEnd, BOOL bBold, COLORREF clr)
{
//
// 格式化选择范围内的文本
//
if (nStart >= nEnd)
return;
DWORD dwEffects = bBold?CFM_BOLD:0;
CHARFORMAT cfm;
cfm.cbSize = sizeof(cfm);
GetSelectionCharFormat(cfm);
if ((cfm.dwMask & CFM_COLOR) && cfm.crTextColor == clr &&
(cfm.dwMask & CFM_BOLD) && (cfm.dwEffects & CFE_BOLD) == dwEffects)
return;
cfm.dwEffects = ~CFE_AUTOCOLOR;
cfm.crTextColor = clr;
cfm.dwMask = CFM_COLOR; // 改变颜色
SetSel(nStart, nEnd);
SetSelectionCharFormat(cfm);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -