📄 basestatic.cpp
字号:
// BaseStatic.cpp : implementation file
//
#include "stdafx.h"
#include "MyProject.h"
#include "BaseStatic.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBaseStatic
CBaseStatic::CBaseStatic()
{
}
CBaseStatic::~CBaseStatic()
{
}
BEGIN_MESSAGE_MAP(CBaseStatic, CStatic)
//{{AFX_MSG_MAP(CBaseStatic)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBaseStatic message handlers
void CBaseStatic::OnPaint()
{
CPaintDC dc(this); // device context for painting
dc.SetBkColor(m_bkColor);
dc.SetTextColor(m_TextColor);
CFont * pfont=this->GetParent()->GetFont();
CFont * pf;
pf=dc.SelectObject(pfont);
// TODO: Add your message handler code here
CString sCaption;
this->GetWindowText(sCaption);
CRect rcWnd;
this->GetClientRect(&rcWnd);
dc.DrawText(sCaption,rcWnd,DT_VCENTER|DT_SINGLELINE);
::DeleteObject(pfont);
// Do not call CStatic::OnPaint() for painting messages
}
void CBaseStatic::SetBkColor(COLORREF bkColor)
{
m_bkColor=bkColor;
}
void CBaseStatic::SetTextColor(COLORREF TextColor)
{
m_TextColor=TextColor;
}
void CBaseStatic::PreSubclassWindow()
{
SetTextColor();
SetBkColor();
CStatic::PreSubclassWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -