colorrichedit.cpp

来自「运用扫描法求设计一个最佳比例的聚光腔」· C++ 代码 · 共 67 行

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

#include "stdafx.h"
#include "ColorRichEdit.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_RBUTTONDOWN()
	//}}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; 
}

void CColorRichEdit::OnRButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	GetCursorPos(&point);
	CMenu menu;

	VERIFY(menu.LoadMenu(IDR_MENU_OUTBAR));

	CMenu* pPopup = menu.GetSubMenu(0);
	ASSERT(pPopup != NULL);
	CWnd* pWndPopupOwner = this;

	while (pWndPopupOwner->GetStyle() & WS_CHILD)
		pWndPopupOwner = pWndPopupOwner->GetParent();

	pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,pWndPopupOwner);

	CRichEditCtrl::OnRButtonDown(nFlags, point);
}

⌨️ 快捷键说明

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