Yao Chunli
2022-06-21 e00d5a1575d26f8fec1be6fa8a844203cd66a24c
提交 | 用户 | age
4b03ae 1 // StaticEx.cpp : 实现文件
Q 2 //
0ed438 3 #include "pch.h"
Q 4 //#include "stdafx.h"
4b03ae 5 #include "StaticEx.h"
Q 6
7
8 // CStaticEx
9
10 // IMPLEMENT_DYNAMIC(CStaticEx, CStatic)
11
12 CStaticEx::CStaticEx()
13 : bCtlColorDef(0)
14 , bTextColorDef(0)
15 {
16     //this->crCtlColor=0x00e0e0e0;
17     //this->crTextColor=0;
18 }
19
20 CStaticEx::~CStaticEx()
21 {
22 }
23
24
25 BEGIN_MESSAGE_MAP(CStaticEx, CStatic)
26 //    ON_WM_CTLCOLOR()
27     ON_WM_CTLCOLOR_REFLECT()
28 END_MESSAGE_MAP()
29
30
31 void CStaticEx::SetCtlColor(COLORREF color)
32 {
33     this->crCtlColor=color;
34     this->bCtlColorDef=true;
0ed438 35     this->RedrawWindow();
4b03ae 36 }
0ed438 37
4b03ae 38 void CStaticEx::SetTextColor(COLORREF color)
Q 39 {
40         this->crTextColor=color;
41         this->bTextColorDef=true;
42 }
43
44 void CStaticEx::SetTextSize(int size)
45 {
46         //this->crTextColor=color;
47         //this->bTextColorDef=true;
48     pFont1.CreateFont(size,0,0,0,FW_NORMAL,0,0,0,GB2312_CHARSET,0,0,0,0,_T("宋体"));
49     this->SetFont(&pFont1,true);
50 //    this->GetFont()->();
51
52 }
53
54 // CStaticEx 消息处理程序
55
56
57
58 //HBRUSH CStaticEx::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
59 //{
60 //    HBRUSH hbr = CStatic::OnCtlColor(pDC, pWnd, nCtlColor);
61 //
62 //    // TODO:  在此更改 DC 的任何属性
63 //
64 //    // TODO:  如果默认的不是所需画笔,则返回另一个画笔
65 //
66 //    pDC->SetBkColor(this->BackgroudColour);
67 //    // TODO: Return a non-NULL brush if the parent's handler should not be called
68 //    ::DeleteObject(m_bkBrush);
69 //    m_bkBrush = ::CreateSolidBrush(this->BackgroudColour);    
70 //    return m_bkBrush;
71 //
72 //    return hbr;
73 //}
74
75 HBRUSH CStaticEx::CtlColor(CDC* pDC, UINT nCtlColor)
76 {
77     // TODO:  在此更改 DC 的任何属性
78
79     // TODO:  如果不应调用父级的处理程序,则返回非空画笔
80     if (this->bTextColorDef)
81     {
82         pDC->SetTextColor(this->crTextColor);
83     }
84     if (this->bCtlColorDef)
85     {
86         pDC->SetBkColor(this->crCtlColor);
87     // TODO: Return a non-NULL brush if the parent's handler should not be called
88     ::DeleteObject(m_bkBrush);
89     m_bkBrush = ::CreateSolidBrush(this->crCtlColor);    
90     return m_bkBrush;
91     }
92     else if (this->bTextColorDef)
93     {
94 //        ::DeleteObject(m_bkBrush);
95 //        m_bkBrush = ::CreateSolidBrush(nCtlColor);    
96 //        return m_bkBrush;
97         
98     }
99     return NULL;
100 }
101