SDC C-Project CF Review 프로그램
LYW
2022-08-05 5f12658f37fed156e67b3318542c98f359341ffd
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// FontStatic.cpp : ±¸Çö ÆÄÀÏÀÔ´Ï´Ù.
//
 
#include "stdafx.h"
#include "FontStatic.h"
 
 
// CFontStatic
IMPLEMENT_DYNAMIC(CFontStatic, CStatic)
 
CFontStatic::CFontStatic()
{
    // Set the font style
    m_bBold = false;
    m_bItalic = false;
    m_bUnderlined = false;
    m_bStrikethrough = false;
    m_bAntialias = false;
 
    // Set the horizontal alignment
    m_bCenter = true;
    m_bLeft = false;
    m_bRight = false;
 
    // Set default font
    m_bBgColor = false;
    m_nSize = 10;
    m_dwColor = RGB(0,0,0);
    m_szFont=_T("MS Sans Serif");
    m_szText = _T("");
}
 
CFontStatic::~CFontStatic()
{
}
 
/////////////////////////////////////////////////////////////////////////////
 
BEGIN_MESSAGE_MAP(CFontStatic, CStatic)
    //{{AFX_MSG_MAP(CFontStatic)
    //}}AFX_MSG_MAP
    ON_WM_PAINT()
END_MESSAGE_MAP()
 
/////////////////////////////////////////////////////////////////////////////
 
void CFontStatic::PreSubclassWindow() 
{
    ModifyStyle(0, SS_NOTIFY, TRUE);
    CStatic::PreSubclassWindow();
}
 
/////////////////////////////////////////////////////////////////////////////
 
void CFontStatic::OnPaint() 
{
    CFont fFont;
    CFont *fOldFont;
    int nWeight;
    CPaintDC dc(this);
    DWORD dwQuality;
    CRect rect;
    UINT unFormat=0;
 
    // Get the client rect
    this->GetClientRect(rect);
 
    // Set the background
    if(m_bBgColor)
        dc.FillSolidRect(rect,m_dwBgColor);
    else
        dc.FillSolidRect(rect,GetSysColor(COLOR_3DFACE));
 
    // Set the text-color and background
    dc.SetTextColor(m_dwColor);
    dc.SetBkMode(TRANSPARENT);
 
    // Determine the weight of the font
    if(m_bBold)
        nWeight = FW_BLACK;
    else
        nWeight = FW_NORMAL;
 
    // Set the quality of the font
    if(m_bAntialias)
        dwQuality = ANTIALIASED_QUALITY;
    else
        dwQuality = DEFAULT_QUALITY;
 
    // Set no prefix and wordwrapping
    unFormat|=DT_SINGLELINE;//DT_NOPREFIX
    unFormat|=DT_WORDBREAK;
    unFormat|=DT_VCENTER;
 
    // Set the horizontal alignment
    if(m_bCenter)
        unFormat|=DT_CENTER;
    else if(m_bRight)
        unFormat|=DT_RIGHT;
    else if(m_bLeft)
        unFormat|=DT_LEFT;
 
    // Create the font
    fFont.Detach();
    if(fFont.CreateFont(m_nSize,0,0,0, nWeight ,m_bItalic, m_bUnderlined, m_bStrikethrough, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, BYTE(dwQuality), DEFAULT_PITCH | FF_DONTCARE, m_szFont)!=NULL)
    {
        fOldFont = dc.SelectObject(&fFont);
        dc.DrawText(m_szText,rect,unFormat);
    }
    else
        AfxMessageBox(_T("Font could not be created!"));
 
}
 
/////////////////////////////////////////////////////////////////////////////
 
void CFontStatic::SetFontStyle(DWORD dwStyle)
{
    // Set the style of the static
    if(dwStyle&FS_BOLD)
        m_bBold = true;
    if(dwStyle&FS_ITALIC)
        m_bItalic = true;
    if(dwStyle&FS_UNDERLINED)
        m_bUnderlined = true;
    if(dwStyle&FS_STRIKETHROUGH)
        m_bStrikethrough = true;
    if(dwStyle&FS_ANTIALIAS)
        m_bAntialias = true;
    if(dwStyle&FS_NORMAL)
    {
        // This will (even if it's combined with other defines) 
        // set all styles to false.
 
        m_bBold = false;
        m_bItalic = false;
        m_bUnderlined = false;
        m_bStrikethrough = false;
        m_bAntialias = false;
        m_bCenter = false;
        m_bLeft = true;
        m_bRight = false;
    }
 
    // Set all alignments to false
    m_bCenter = true;
    m_bLeft = false;
    m_bRight = false;
 
    // Set the horizontal alignment
    if(dwStyle&FS_CENTER)
        m_bCenter = true;
    else if(dwStyle&FS_RIGHT)
        m_bRight = true;
    else if(dwStyle&FS_LEFT)
        m_bLeft = true;
    else
        m_bLeft = true;
}
 
/////////////////////////////////////////////////////////////////////////////
 
void CFontStatic::SetBackground(DWORD dwBgColor)
{
    // Set the background color
    m_dwBgColor = dwBgColor;
    m_bBgColor = true;
    Invalidate(TRUE);
}
 
/////////////////////////////////////////////////////////////////////////////
 
void CFontStatic::SetFontStatic(CString szFont, int nSize, DWORD dwColor, DWORD dwStyle)
{
    // Set the font, size and color.
    m_szFont = szFont;
    m_nSize = nSize;
    m_dwColor = dwColor;
 
    // Set the style
    SetFontStyle(dwStyle);
}
 
void CFontStatic::SetWindowText(LPCTSTR a_lpstr)
{
    m_szText = a_lpstr;
    
    Invalidate(TRUE);
}
 
 
/////////////////////////////////////////////////////////////////////////////
 
 
// CFontStatic ¸Þ½ÃÁö Ã³¸®±âÀÔ´Ï´Ù.