📄 colorstatic.cpp
字号:
// This file was created on March 28th 2001 by Robert Brault.
// I created this Class to be able change the Color of your Static Text.
// This is Derived from CStatic.
//
// There are three functions available Currently:
// SetBkColor(COLORREF crColor)
// SetTextColor(COLORREF crColor)
//
// How To Use:
// Add three files to your project
// ColorStatic.cpp, ColorStatic.h and Color.h
// Color.h has (#define)'s for different colors (add any color you desire).
//
// Add #include "ColorStatic.h" to your Dialogs Header file.
// Declare an instance of CColorStatic for each static text being modified.
// Ex. CColorStatic m_stText;
//
// In your OnInitDialog() add a SubclassDlgItem for each CColorStatic member variable.
// Ex. m_stText.SubclassDlgItem(IDC_ST_TEXT, this);
// In this same function initialize your color for each piece of text unless you want the default.
// ColorStatic.cpp : implementation file
//
/**
***************************************************************
* 文件名: ColorStatic
* 版 权: Copyright (c) 2006-2020 中兴软件技术(南昌)有限公司
* 创建人: 袁军
* 日 期: 2007/12/13
* 版 本: V1.0
* 描 述: 该类CStatic控件的美化
* 修改记录:
* 修改人 修改日期 修改描述
*
***************************************************************
*/
#include "stdafx.h"
#include "ColorStatic.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CColorStatic
/**
*************************************************************
* 函 数 名: CColorStatic()
* 描 述: 该类的构造函数
* 数 据 库: 无
* 数据库表: 无
* 输入参数: 无
* 输出参数: 无
* 返 回 值: 无
* 创 建 人: 袁军
* 日 期: 2007/12/13
* 修改记录:
* 修改人 修改日期 修改描述
*************************************************************
*/
CColorStatic::CColorStatic()
{
//m_crBkColor = ::GetSysColor(COLOR_3DFACE); // Initializing the Background Color to the system face color.
m_crBkColor = RGB(255,255,255);
m_crTextColor = RGB(0,0,0); // Initializing the text to Black
//m_brBkgnd.CreateSolidBrush(m_crBkColor); // Create the Brush Color for the Background.
//m_brBkgnd.CreateSolidBrush(RGB(255,255,255));
}
/**
*************************************************************
* 函 数 名: ~CColorStatic()
* 描 述: 该类的析构函数
* 数 据 库: 无
* 数据库表: 无
* 输入参数: 无
* 输出参数: 无
* 返 回 值: 无
* 创 建 人: 袁军
* 日 期: 2007/12/13
* 修改记录:
* 修改人 修改日期 修改描述
*************************************************************
*/
CColorStatic::~CColorStatic()
{
}
BEGIN_MESSAGE_MAP(CColorStatic, CStatic)
//{{AFX_MSG_MAP(CColorStatic)
ON_WM_CTLCOLOR_REFLECT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CColorStatic message handlers
/**
*************************************************************
* 函 数 名: CtlColor(CDC* pDC, UINT nCtlColor)
* 描 述: 选择要绘制的字体与背景色
* 数 据 库: 无
* 数据库表: 无
* 输入参数: 无
* 输出参数: 无
* 返 回 值: 无
* 创 建 人: 袁军
* 日 期: 2007/12/13
* 修改记录:
* 修改人 修改日期 修改描述
*************************************************************
*/
HBRUSH CColorStatic::CtlColor(CDC* pDC, UINT nCtlColor)
{
HBRUSH hbr;
hbr = (HBRUSH)m_brBkgnd; // Passing a Handle to the Brush
pDC->SetBkColor(m_crBkColor); // Setting the Color of the Text Background to the one passed by the Dialog
pDC->SetTextColor(m_crTextColor); // Setting the Text Color to the one Passed by the Dialog
return hbr;
}
/**
*************************************************************
* 函 数 名: SetBkColor(COLORREF crColor)
* 描 述: 设置背景色
* 数 据 库: 无
* 数据库表: 无
* 输入参数: COLORREF crColor:背景颜色值
* 输出参数: 无
* 返 回 值: 无
* 创 建 人: 袁军
* 日 期: 2007/12/13
* 修改记录:
* 修改人 修改日期 修改描述
*************************************************************
*/
void CColorStatic::SetBkColor(COLORREF crColor)
{
m_crBkColor = crColor; // Passing the value passed by the dialog to the member varaible for Backgound Color
m_brBkgnd.DeleteObject(); // Deleting any Previous Brush Colors if any existed.
m_brBkgnd.CreateSolidBrush(crColor); // Creating the Brush Color For the Static Text Background
RedrawWindow();
}
/**
*************************************************************
* 函 数 名: SetTextColor(COLORREF crColor)
* 描 述: 设置字体色
* 数 据 库: 无
* 数据库表: 无
* 输入参数: COLORREF crColor:字体显示的颜色值
* 输出参数: 无
* 返 回 值: 无
* 创 建 人: 袁军
* 日 期: 2007/12/13
* 修改记录:
* 修改人 修改日期 修改描述
*************************************************************
*/
void CColorStatic::SetTextColor(COLORREF crColor)
{
m_crTextColor = crColor; // Passing the value passed by the dialog to the member varaible for Text Color
RedrawWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -