📄 flagstatic.cpp
字号:
// FlagStatic.cpp : implementation file
//
#include "stdafx.h"
#include "DvsUser.h"
#include "FlagStatic.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFlagStatic
//----------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------
CFlagStatic::CFlagStatic()
{
m_crNormal = RGB(0, 255, 0);
m_crAlert = RGB(255, 0, 0);
m_crPaint = m_crNormal;
m_strTitle = _TEXT("万力电子远程监控系统");
B = 1;
m_bState = 0;
LOGFONT logFont;
ZeroMemory(&logFont, sizeof(LOGFONT));
logFont.lfHeight = 0xfffffff1;
logFont.lfWeight = 0x290;
logFont.lfWidth = 0;
logFont.lfCharSet = 0x86;
logFont.lfOutPrecision = 0x03;
logFont.lfClipPrecision= 0x02;
logFont.lfQuality = 0x01;
logFont.lfPitchAndFamily= 0x31;
sprintf(logFont.lfFaceName, _TEXT("楷体_GB2312"));
m_lf.CreateFontIndirect(&logFont);
}
//----------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------
CFlagStatic::~CFlagStatic()
{
m_lf.DeleteObject();
}
//----------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------
BEGIN_MESSAGE_MAP(CFlagStatic, CStatic)
//{{AFX_MSG_MAP(CFlagStatic)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFlagStatic message handlers
//----------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------
VOID CFlagStatic::ChangeColor(COLORREF crNormal, COLORREF crAlert)
{
m_crNormal = crNormal;
m_crAlert = crAlert;
if(m_bState)
SetAlert();
else
SetNormal();
}
//----------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------
VOID CFlagStatic::SetAlert()
{
m_bState = 1;
m_crPaint = m_crAlert;
Invalidate();
B = 0;
}
//----------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------
VOID CFlagStatic::SetNormal()
{
m_bState = 0;
m_crPaint = m_crNormal;
Invalidate();
}
//----------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------
COLORREF CFlagStatic::GetAlert()
{
return m_crAlert;
}
//----------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------
COLORREF CFlagStatic::GetNormal()
{
return m_crNormal;
}
//----------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------
VOID CFlagStatic::SetTitle(CString strTitle)
{
m_strTitle = strTitle;
Invalidate();
}
//----------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------
VOID CFlagStatic::GetTitle(CString& strTitle)
{
strTitle = m_strTitle;
}
//----------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------
VOID CFlagStatic::SetFlagFont(LOGFONT lf)
{
}
//----------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------
VOID CFlagStatic::GetFlagFont(LOGFONT& lf)
{
}
//----------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------
void CFlagStatic::OnPaint()
{
CPaintDC dc(this); // device context for painting
CBrush brush(m_crPaint);
RECT rc;
CFont* fOld;
GetClientRect(&rc);
dc.FillRect(&rc, &brush);
dc.SetBkColor(m_crPaint);
dc.SetTextColor(RGB(0,0,0));
fOld = (CFont*)dc.SelectObject(&m_lf);
dc.TextOut(0, 0, m_strTitle);
dc.SelectObject(fOld);
// Do not call CStatic::OnPaint() for painting messages
}
//----------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------
void CFlagStatic::OnLButtonDown(UINT nFlags, CPoint point)
{
if(B)
{
SetAlert();
B = 0;
}
else
{
::PlaySound(NULL, NULL, SND_ASYNC);
SetNormal();
B = 1;
}
CStatic::OnLButtonDown(nFlags, point);
}
//----------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -