QuakeGod
2021-07-29 3b04f942bd51c0453cbb64167cbdb7de69159bd5
提交 | 用户 | age
4b03ae 1 // StaticEx.cpp : 实现文件
Q 2 //
3
4 #include "stdafx.h"
5 #include "StaticEx.h"
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;
35 }
36 void CStaticEx::SetTextColor(COLORREF color)
37 {
38         this->crTextColor=color;
39         this->bTextColorDef=true;
40 }
41
42 void CStaticEx::SetTextSize(int size)
43 {
44         //this->crTextColor=color;
45         //this->bTextColorDef=true;
46     pFont1.CreateFont(size,0,0,0,FW_NORMAL,0,0,0,GB2312_CHARSET,0,0,0,0,_T("宋体"));
47     this->SetFont(&pFont1,true);
48 //    this->GetFont()->();
49
50 }
51
52 // CStaticEx 消息处理程序
53
54
55
56 //HBRUSH CStaticEx::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
57 //{
58 //    HBRUSH hbr = CStatic::OnCtlColor(pDC, pWnd, nCtlColor);
59 //
60 //    // TODO:  在此更改 DC 的任何属性
61 //
62 //    // TODO:  如果默认的不是所需画笔,则返回另一个画笔
63 //
64 //    pDC->SetBkColor(this->BackgroudColour);
65 //    // TODO: Return a non-NULL brush if the parent's handler should not be called
66 //    ::DeleteObject(m_bkBrush);
67 //    m_bkBrush = ::CreateSolidBrush(this->BackgroudColour);    
68 //    return m_bkBrush;
69 //
70 //    return hbr;
71 //}
72
73 HBRUSH CStaticEx::CtlColor(CDC* pDC, UINT nCtlColor)
74 {
75     // TODO:  在此更改 DC 的任何属性
76
77     // TODO:  如果不应调用父级的处理程序,则返回非空画笔
78     if (this->bTextColorDef)
79     {
80         pDC->SetTextColor(this->crTextColor);
81     }
82     if (this->bCtlColorDef)
83     {
84         pDC->SetBkColor(this->crCtlColor);
85     // TODO: Return a non-NULL brush if the parent's handler should not be called
86     ::DeleteObject(m_bkBrush);
87     m_bkBrush = ::CreateSolidBrush(this->crCtlColor);    
88     return m_bkBrush;
89     }
90     else if (this->bTextColorDef)
91     {
92 //        ::DeleteObject(m_bkBrush);
93 //        m_bkBrush = ::CreateSolidBrush(nCtlColor);    
94 //        return m_bkBrush;
95         
96     }
97     return NULL;
98 }
99