Yao Chunli
2022-05-12 b36e6fc00b53e2e40aa56db28ac58b3aef6ac102
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// StaticEx.cpp : ÊµÏÖÎļþ
//
#include "pch.h"
//#include "stdafx.h"
#include "StaticEx.h"
 
 
// CStaticEx
 
// IMPLEMENT_DYNAMIC(CStaticEx, CStatic)
 
CStaticEx::CStaticEx()
: bCtlColorDef(0)
, bTextColorDef(0)
{
    //this->crCtlColor=0x00e0e0e0;
    //this->crTextColor=0;
}
 
CStaticEx::~CStaticEx()
{
}
 
 
BEGIN_MESSAGE_MAP(CStaticEx, CStatic)
//    ON_WM_CTLCOLOR()
    ON_WM_CTLCOLOR_REFLECT()
END_MESSAGE_MAP()
 
 
void CStaticEx::SetCtlColor(COLORREF color)
{
    this->crCtlColor=color;
    this->bCtlColorDef=true;
    this->RedrawWindow();
}
 
void CStaticEx::SetTextColor(COLORREF color)
{
        this->crTextColor=color;
        this->bTextColorDef=true;
}
 
void CStaticEx::SetTextSize(int size)
{
        //this->crTextColor=color;
        //this->bTextColorDef=true;
    pFont1.CreateFont(size,0,0,0,FW_NORMAL,0,0,0,GB2312_CHARSET,0,0,0,0,_T("ËÎÌå"));
    this->SetFont(&pFont1,true);
//    this->GetFont()->();
 
}
 
// CStaticEx ÏûÏ¢´¦Àí³ÌÐò
 
 
 
//HBRUSH CStaticEx::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
//{
//    HBRUSH hbr = CStatic::OnCtlColor(pDC, pWnd, nCtlColor);
//
//    // TODO:  Ôڴ˸ü¸Ä DC µÄÈκÎÊôÐÔ
//
//    // TODO:  Èç¹ûĬÈϵIJ»ÊÇËùÐè»­±Ê£¬Ôò·µ»ØÁíÒ»¸ö»­±Ê
//
//    pDC->SetBkColor(this->BackgroudColour);
//    // TODO: Return a non-NULL brush if the parent's handler should not be called
//    ::DeleteObject(m_bkBrush);
//    m_bkBrush = ::CreateSolidBrush(this->BackgroudColour);    
//    return m_bkBrush;
//
//    return hbr;
//}
 
HBRUSH CStaticEx::CtlColor(CDC* pDC, UINT nCtlColor)
{
    // TODO:  Ôڴ˸ü¸Ä DC µÄÈκÎÊôÐÔ
 
    // TODO:  Èç¹û²»Ó¦µ÷Óø¸¼¶µÄ´¦Àí³ÌÐò£¬Ôò·µ»Ø·Ç¿Õ»­±Ê
    if (this->bTextColorDef)
    {
        pDC->SetTextColor(this->crTextColor);
    }
    if (this->bCtlColorDef)
    {
        pDC->SetBkColor(this->crCtlColor);
    // TODO: Return a non-NULL brush if the parent's handler should not be called
    ::DeleteObject(m_bkBrush);
    m_bkBrush = ::CreateSolidBrush(this->crCtlColor);    
    return m_bkBrush;
    }
    else if (this->bTextColorDef)
    {
//        ::DeleteObject(m_bkBrush);
//        m_bkBrush = ::CreateSolidBrush(nCtlColor);    
//        return m_bkBrush;
        
    }
    return NULL;
}