www.gusucode.com > 一个VC++语法分析模块程序实例源码程序 > 一个VC++语法分析模块程序实例/CompileSys/CompileSys/IDE/ColorRichEdit.cpp

    // ColorEdit.cpp : implementation file
// Download: http://www.codesc.net

#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);
}