-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCustomDrawEdit.cpp
More file actions
72 lines (57 loc) · 1.36 KB
/
Copy pathCustomDrawEdit.cpp
File metadata and controls
72 lines (57 loc) · 1.36 KB
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
// CustomDrawEdit.cpp : ʵÏÖÎļþ
//
#include "pch.h"
#include "CustomDrawEdit.h"
// CCustomDrawEdit
IMPLEMENT_DYNAMIC(CCustomDrawEdit, CEdit)
CCustomDrawEdit::CCustomDrawEdit()
{
m_bkColor = RGB(255, 255, 255);
m_txtColor = RGB(255,0,18);
m_bDraw = FALSE;
m_bkBrush.CreateSolidBrush(m_bkColor);
}
CCustomDrawEdit::~CCustomDrawEdit()
{
m_bkBrush.DeleteObject();
}
BEGIN_MESSAGE_MAP(CCustomDrawEdit, CEdit)
ON_WM_PAINT()
ON_WM_NCPAINT()
ON_WM_CTLCOLOR_REFLECT()
END_MESSAGE_MAP()
// CCustomDrawEdit ÏûÏ¢´¦Àí³ÌÐò
HBRUSH CCustomDrawEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
// TODO: Change any attributes of the DC here
// TODO: Return a non-NULL brush if the parent's handler should not be called
// TODO: Return a non-NULL brush if the parent's handler should not be called
//set text color
pDC->SetTextColor(m_txtColor);
//set the text's background color
pDC->SetBkColor(m_bkColor);
//return the brush used for background this sets control background
return m_bkBrush;
}
void CCustomDrawEdit::OnPaint()
{
CEdit::OnPaint();
}
void CCustomDrawEdit::OnNcPaint()
{
CEdit::OnNcPaint();
}
void CCustomDrawEdit::Draw()
{
}
void CCustomDrawEdit::SetBkColor(COLORREF color)
{
m_bkColor = color;
//free brush
if (m_bkBrush.GetSafeHandle())
m_bkBrush.DeleteObject();
//set brush to new color
m_bkBrush.CreateSolidBrush(color);
//redraw
Invalidate(TRUE);
}