mrDarker
2025-07-16 1dbe46cd9d0f181d08d5a69f72d8548628a13b9d
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
 
#include "StdAfx.h"
#include "General_Draw.h"
#include "Server_MemDC.h"
 
CGeneralDraw::CGeneralDraw(void)
{
}
 
CGeneralDraw::~CGeneralDraw(void)
{
}
 
void CGeneralDraw::DrawPitureControl(CUIPictureControl &pPicture)
{
    if(pPicture.isVaildDC() == FALSE)
        return;
    
    CBrush        brush,backbrush,brushDisable;    
    HFONT        font,pOldFont;    
    HDC            hDC;
    CRect        rect = pPicture.m_rect;
    
    // create font
    font = ::CreateFont(pPicture.m_nFontsize, 0, 0, 0, pPicture.m_nFontType, 0, 0, 0,
        DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,
        ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DECORATIVE, pPicture.m_strFont);    
    
    CControlMemDC memDC(pPicture.m_pDC, &rect);    
    hDC = memDC.GetSafeHdc();
    
    pOldFont = (HFONT) ::SelectObject(hDC, font);        
    if(::GetTextColor(hDC) != pPicture.m_colText) ::SetTextColor(hDC, pPicture.m_colText);
    ::SetBkMode(hDC, TRANSPARENT);    
    
    brushDisable.CreateSolidBrush(RGB(128,128,128));
    brush.CreateSolidBrush(pPicture.m_colInner);
    backbrush.CreateSolidBrush(pPicture.m_colBack);
    ::FillRect(hDC,&rect,(HBRUSH)backbrush);
    rect.left += pPicture.m_nInnerOffset;
    rect.right -= pPicture.m_nInnerOffset;
    rect.top += pPicture.m_nInnerOffset;
    rect.bottom -= pPicture.m_nInnerOffset;            
    
    if(pPicture.m_bEnable == TRUE)
    {
        ::FillRect(hDC,&rect,(HBRUSH)brush);
        rect.left += pPicture.m_FontOffset.x;
        rect.top += pPicture.m_FontOffset.y;
        ::DrawText(hDC, pPicture.m_strData, pPicture.m_strData.GetLength(), &rect, pPicture.m_nAlign);
    }
    else
    {
        ::FillRect(hDC,&rect,(HBRUSH)brushDisable);
    }
    
    brush.DeleteObject();
    backbrush.DeleteObject();
    brushDisable.DeleteObject();
    ::DeleteObject(::SelectObject(hDC, (HFONT)pOldFont));    
    ::DeleteObject(font);
}