58 lines
1.4 KiB
C++
58 lines
1.4 KiB
C++
|
|
#include "stdafx.h"
|
|
#include "shsFlatCaption.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// 构造/卸构 函数
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
CHYFlatCaption::CHYFlatCaption()
|
|
{
|
|
m_capRect = CRect(0, 0, 10, 10);
|
|
m_captionText = _T("上华软件");
|
|
}
|
|
|
|
CHYFlatCaption::~CHYFlatCaption()
|
|
{
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// 成员函数
|
|
//////////////////////////////////////////////////////////////////////////
|
|
void CHYFlatCaption::Paint(CDC* pDC)
|
|
{
|
|
COLORREF m_clrBtnShadow = ::GetSysColor(COLOR_BTNSHADOW);
|
|
pDC->Draw3dRect(m_capRect, m_clrBtnShadow, m_clrBtnShadow);
|
|
|
|
COLORREF oldTextColor = pDC->SetTextColor(RGB(0,0,0)); // 设置文字颜色
|
|
int nPrevBkMode = pDC->SetBkMode(TRANSPARENT); // 设置绘制文字背景为透明
|
|
|
|
// Get the log font.
|
|
CFont m_Font;
|
|
NONCLIENTMETRICS ncm;
|
|
ncm.cbSize = sizeof(NONCLIENTMETRICS);
|
|
VERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
|
|
sizeof(NONCLIENTMETRICS), &ncm, 0));
|
|
m_Font.CreateFontIndirect(&ncm.lfMessageFont);
|
|
|
|
CFont *pOldFont = pDC->SelectObject(&m_Font);
|
|
|
|
CRect rc(m_capRect);
|
|
rc.DeflateRect(2, 2);
|
|
rc.left += 8;
|
|
rc.top += 1;
|
|
|
|
pDC->DrawText(m_captionText, rc, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
|
|
|
|
pDC->SelectObject(pOldFont);
|
|
pDC->SetTextColor(oldTextColor);
|
|
pDC->SetBkMode(nPrevBkMode);
|
|
}
|
|
|