colorstatic.cpp

来自「通过vc语言从任意一个文件夹的读出文件名和路径操作的程序」· C++ 代码 · 共 62 行

CPP
62
字号
// ColorStatic.cpp : implementation file
//

#include "stdafx.h"
#include "ExtractFileList.h"
#include "ColorStatic.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CColorStatic

CColorStatic::CColorStatic()
{
}

CColorStatic::~CColorStatic()
{
}

BEGIN_MESSAGE_MAP(CColorStatic, CStatic)
	//{{AFX_MSG_MAP(CColorStatic)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CColorStatic message handlers

void CColorStatic::SetTextColor(COLORREF crTextColor)
{
    m_crTextColor = crTextColor;
}

void CColorStatic::OnPaint() 
{
	CPaintDC dc(this);
	dc.SetTextColor(m_crTextColor);
	dc.SetBkMode(TRANSPARENT);
	dc.SelectObject(this->GetFont());

	CRect rect;
	CBrush BGBrush;
	int nTextLeft = 0, nTextTop = 0;

	this->GetClientRect(&rect);

	TEXTMETRIC tm;
	dc.GetTextMetrics(&tm);
	CString strText;
	this->GetWindowText(strText);
	nTextTop = rect.top + ((rect.Height()-tm.tmHeight) >> 1);

	if (strText.GetLength() > 0)
	{	
		dc.TextOut(nTextLeft, nTextTop, strText);
	}
}

⌨️ 快捷键说明

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