⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myricheditctrl.cpp

📁 背单词程序
💻 CPP
字号:
// MyRichEditCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "EngRecite.h"
#include "MyRichEditCtrl.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMyRichEditCtrl

CMyRichEditCtrl::CMyRichEditCtrl()
{
}

CMyRichEditCtrl::~CMyRichEditCtrl()
{
}


BEGIN_MESSAGE_MAP(CMyRichEditCtrl, CRichEditCtrl)
	//{{AFX_MSG_MAP(CMyRichEditCtrl)
	ON_WM_CHAR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyRichEditCtrl message handlers

void CMyRichEditCtrl::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	CRichEditCtrl::OnChar(nChar, nRepCnt, nFlags);

	static BOOL bRepType = FALSE;
	
	UINT nInsertChar = 0;
	switch(nChar)
	{
	case '[':
		nInsertChar = ']';
		break;
	case '{':
		nInsertChar = '}';
		break;
	case '(':
		nInsertChar = ')';
		break;
	case '<':
		nInsertChar = '>';
		break;
	case '"':
		bRepType = ~bRepType;
		nInsertChar = bRepType ? '"' : 0;
		break;
	case '\'':
		bRepType = ~bRepType;
		nInsertChar = bRepType ? '\'' : 0;
		break;
	default:
		break;
	}
	
	if (nInsertChar != 0)
	{
		SendMessage(WM_CHAR, (WPARAM)nInsertChar, (LPARAM)((nRepCnt & 0x00FF) | ((nFlags << 16) & 0xFF00)));
		
		SendMessage(WM_KEYDOWN, (WPARAM)37, (LPARAM)((1  & 0x00FF) | ((331 << 16)   & 0xFF00)));
		SendMessage(WM_KEYUP,   (WPARAM)37, (LPARAM)((1  & 0x00FF) | ((49483 << 16) & 0xFF00)));
		
		SetSel(-1, 0);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -