colorrichedit.cpp

来自「一个非常好的词法分析程序,加上语法的分析是一个难得一见的好实例」· C++ 代码 · 共 85 行

CPP
85
字号
// ColorEdit.cpp : implementation file
//

#include "stdafx.h"
#include "ColorRichEdit.h"
#include "MainFrm.h"

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

/////////////////////////////////////////////////////////////////////////////
// CColorRichEdit

CColorRichEdit::CColorRichEdit()
{
}

CColorRichEdit::~CColorRichEdit()
{
}


BEGIN_MESSAGE_MAP(CColorRichEdit, CRichEditCtrl)
	//{{AFX_MSG_MAP(CColorRichEdit)
	ON_WM_CTLCOLOR_REFLECT()
	ON_WM_RBUTTONUP()
	ON_COMMAND(IDM_CLEAR, OnClear)
	ON_COMMAND(IDM_HIDE_OUTBAR, OnHideOutbar)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CColorRichEdit message handlers

HBRUSH CColorRichEdit::CtlColor(CDC* pDC, UINT nCtlColor) 
{
	// TODO: Change any attributes of the DC here
	COLORREF clrBack=RGB(0,0,0);
	COLORREF clrText=RGB(0,255,0);

	pDC->SetTextColor(clrText);  
	pDC->SetBkColor(clrBack);   
	m_bkBrush = ::CreateSolidBrush(clrBack);
	// TODO: Return a non-NULL brush if the parent's handler should not be called
	return m_bkBrush; 
}

BOOL CColorRichEdit::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CRichEditCtrl::OnCommand(wParam, lParam);
}

void CColorRichEdit::OnRButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	BCMenu *menuPopup;
	BCMenu menu;

	menu.LoadMenu(IDR_MENU_OUTBAR);
	menuPopup=(BCMenu*)menu.GetSubMenu(0);

	ClientToScreen(&point);
	menuPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,this);
	menuPopup->DestroyMenu();
}

void CColorRichEdit::OnClear() 
{
	// TODO: Add your command handler code here
	SetWindowText("");
}

void CColorRichEdit::OnHideOutbar() 
{
	// TODO: Add your command handler code here
	CMainFrame* pMainFrame=((CMainFrame*)::AfxGetMainWnd());

	pMainFrame->ShowControlBar(pMainFrame->GetOutBar(),0,1);
}

⌨️ 快捷键说明

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