-
Notifications
You must be signed in to change notification settings - Fork 0
/
CNFStatic.cpp
81 lines (61 loc) · 1.81 KB
/
CNFStatic.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "stdafx.h"
#include "CNFStatic.h"
CNFStatic::CNFStatic()
{
}
CNFStatic::~CNFStatic()
{
}
BEGIN_MESSAGE_MAP(CNFStatic, CStatic)
ON_WM_ERASEBKGND()
ON_WM_PAINT()
END_MESSAGE_MAP()
// CNFStatic 消息处理程序
//----------------------------------------------------------------------------------------------------------------------
BOOL CNFStatic::OnEraseBkgnd(CDC* pDC)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
// return CStatic::OnEraseBkgnd(pDC);
return TRUE;
}
//----------------------------------------------------------------------------------------------------------------------
void CNFStatic::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: 在此处添加消息处理程序代码
// 不为绘图消息调用 CStatic::OnPaint()
CRect rect;
GetClientRect(&rect);
if (!dcMem)
PrepareMemDC(dc, rect.Width(), rect.Height());
Draw(dcMem, rect, &dc);
}
//----------------------------------------------------------------------------------------------------------------------
void CNFStatic::Draw(CDC& dc, CRect& rect, CDC* pDCTarget)
{
if (dc)
{
CRect rt = rect;
dc.FillSolidRect(rect, ::GetSysColor(COLOR_INFOBK));
dc.DrawFocusRect(&rt);
rt.DeflateRect(2, 2);
dc.DrawText(strContent, &rt, DT_LEFT | DT_EXPANDTABS);
if (pDCTarget)
{
pDCTarget->BitBlt(0, 0, rect.Width(), rect.Height(), &dc, 0, 0, SRCCOPY);
}
}
}
//----------------------------------------------------------------------------------------------------------------------
void CNFStatic::PrepareMemDC(CDC& dc, int nw, int nh)
{
if (bmp.operator HBITMAP())
bmp.DeleteObject();
if (dcMem)
dcMem.DeleteDC();
dcMem.CreateCompatibleDC(&dc);
bmp.CreateCompatibleBitmap(&dc, nw, nh);
dcMem.SelectObject(bmp);
dcMem.SelectStockObject(SYSTEM_FONT);
dcMem.SetTextColor(::GetSysColor(COLOR_INFOTEXT));
}