-
Notifications
You must be signed in to change notification settings - Fork 6
/
CBackCol.h
75 lines (53 loc) · 1.17 KB
/
CBackCol.h
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
// static back color CBackCol
#include <atlbase.h>
#include <AtlApp.h>
#include <atlwin.h>
#include <AtlCrack.h>
#include <AtlMisc.h>
#include <AtlScrl.h>
#include <AtlCtrls.h>
class CBackCol;
typedef CWindowImpl<CBackCol, CStatic> CBackColBase;
class CBackCol : public CBackColBase
{
COLORREF m_Color;
HBRUSH m_Background;
public:
CBackCol() : CBackColBase()
{
m_Color = ::GetSysColor(COLOR_BACKGROUND);
m_Background = NULL;
}
~CBackCol()
{
if (m_Background)
::DeleteObject(m_Background);
}
void SetBkColor(COLORREF Col)
{
m_Color = Col;
if (m_Background)
{
::DeleteObject(m_Background);
m_Background = NULL;
}
RedrawWindow();
}
COLORREF GetBkColor() const
{
return m_Color;
}
BEGIN_MSG_MAP(CBackCol)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
END_MSG_MAP()
LRESULT OnPaint(UINT, WPARAM wParam, LPARAM, BOOL& bHandled)
{
if (NULL == m_Background)
m_Background = CreateSolidBrush(m_Color);
CPaintDC dc(m_hWnd);
CRect rc;
GetClientRect(rc);
dc.FillRect(rc, m_Background);
return 0;
}
};