QuakeGod
2021-07-29 3b04f942bd51c0453cbb64167cbdb7de69159bd5
提交 | 用户 | age
4b03ae 1 #pragma once
Q 2
3
4 // CStaticEx
5
6 class CStaticEx //: public CStatic
7 {
8 //    DECLARE_DYNAMIC(CStaticEx)
9
10 public:
11 CStaticEx::CStaticEx()
12 : bCtlColorDef(0)
13 , bTextColorDef(0)
14 {
15     //this->crCtlColor=0x00e0e0e0;
16     //this->crTextColor=0;
17 }
18
19 CStaticEx::~CStaticEx()
20 {
21 }
22
23 private:
24     HBRUSH        m_bkBrush;
25     COLORREF    crCtlColor;
26     COLORREF    crTextColor;
27 public:
28     int bCtlColorDef;
29 public:
30     int bTextColorDef;
31 public:
32     CFont pFont1;
33     
34 // Attributes
35 public:
36 //    void SetCtlColor(COLORREF color);
37 //IMPLEMENT_DYNAMIC(CStaticEx, CStatic)
38 protected:
39 //    DECLARE_MESSAGE_MAP()
40 public:
41 //    afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
42 public:
43 //    afx_msg HBRUSH CtlColor(CDC* /*pDC*/, UINT /*nCtlColor*/);
44 public:
45 //    void SetTextColor(COLORREF color);
46
47 public:
48 //    void SetTextSize(int size);
49
50
51 // CStaticEx
52
53 /*
54     BEGIN_MESSAGE_MAP(CStaticEx, CStatic)
55         //    ON_WM_CTLCOLOR()
56         ON_WM_CTLCOLOR_REFLECT()
57     END_MESSAGE_MAP()
58 */
59
60
61
62
63
64 void CStaticEx::SetCtlColor(COLORREF color)
65 {
66     this->crCtlColor=color;
67     this->bCtlColorDef=true;
68 }
69 void CStaticEx::SetTextColor(COLORREF color)
70 {
71         this->crTextColor=color;
72         this->bTextColorDef=true;
73 }
74
75 void CStaticEx::SetTextSize(int size)
76 {
77         //this->crTextColor=color;
78         //this->bTextColorDef=true;
79     pFont1.CreateFont(size,0,0,0,FW_NORMAL,0,0,0,GB2312_CHARSET,0,0,0,0,_T("宋体"));
80 //    this->SetFont(&pFont1,true);
81 //    this->GetFont()->();
82
83 }
84
85 // CStaticEx 消息处理程序
86
87
88
89 //HBRUSH CStaticEx::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
90 //{
91 //    HBRUSH hbr = CStatic::OnCtlColor(pDC, pWnd, nCtlColor);
92 //
93 //    // TODO:  在此更改 DC 的任何属性
94 //
95 //    // TODO:  如果默认的不是所需画笔,则返回另一个画笔
96 //
97 //    pDC->SetBkColor(this->BackgroudColour);
98 //    // TODO: Return a non-NULL brush if the parent's handler should not be called
99 //    ::DeleteObject(m_bkBrush);
100 //    m_bkBrush = ::CreateSolidBrush(this->BackgroudColour);    
101 //    return m_bkBrush;
102 //
103 //    return hbr;
104 //}
105
106 HBRUSH CStaticEx::CtlColor(CDC* pDC, UINT nCtlColor)
107 {
108     // TODO:  在此更改 DC 的任何属性
109
110     // TODO:  如果不应调用父级的处理程序,则返回非空画笔
111     if (this->bTextColorDef)
112     {
113         pDC->SetTextColor(this->crTextColor);
114     }
115     if (this->bCtlColorDef)
116     {
117         pDC->SetBkColor(this->crCtlColor);
118     // TODO: Return a non-NULL brush if the parent's handler should not be called
119     ::DeleteObject(m_bkBrush);
120     m_bkBrush = ::CreateSolidBrush(this->crCtlColor);    
121     return m_bkBrush;
122     }
123     else if (this->bTextColorDef)
124     {
125         ::DeleteObject(m_bkBrush);
126         m_bkBrush = ::CreateSolidBrush(nCtlColor);    
127         return m_bkBrush;
128
129     }
130     return NULL;
131 }
132
133 };
134