www.pudn.com > RADAR-ALARM.rar > AlertLight.cpp, change:2011-07-31,size:954b


#include "StdAfx.h" 
#include "AlertLight.h" 
 
CAlertLight::CAlertLight(void) 
: m_AlertSignal(false) 
{ 
} 
 
CAlertLight::~CAlertLight(void) 
{ 
} 
BEGIN_MESSAGE_MAP(CAlertLight, CStatic) 
	ON_WM_PAINT() 
END_MESSAGE_MAP() 
 
void CAlertLight::OnPaint() 
{ 
	CPaintDC dc(this); // device context for painting 
	// TODO: 在此处添加消息处理程序代码 
	// 不为绘图消息调用 CStatic::OnPaint() 
	CDC*pDC=GetDC(); 
	CRect rect; 
	GetClientRect(rect); 
    CBrush BGBrush,Brush;//底色涂黑 
    CBrush*OldBrush; 
	if(this->m_AlertSignal==true) 
	{ 
    BGBrush.CreateSolidBrush(RGB(255,0,0)); 
    OldBrush=pDC->SelectObject(&BGBrush); 
    pDC->Rectangle(&rect); 
	pDC->SelectObject(&OldBrush); 
	} 
	else 
	{ 
      BGBrush.CreateSolidBrush(RGB(0,255,0)); 
    OldBrush=pDC->SelectObject(&BGBrush); 
    pDC->Rectangle(&rect); 
	pDC->SelectObject(&OldBrush); 
	} 
} 
 
void CAlertLight::SetLight(bool flag) 
{ 
	m_AlertSignal=flag; 
	this->Invalidate(); 
}