admin
2024-03-04 9be57d2f294687a9283e6d3ed8599def4faf1fec
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
#include "common/pch.h"
#include "CImgButton.h"
 
CImgButton::CImgButton()
{
}
 
 
CImgButton::~CImgButton()
{
}
 
// BEGIN_MESSAGE_MAP(CImgButton, CBitmapButton)
// END_MESSAGE_MAP()
 
void CImgButton::SetTextColor(COLORREF crColor)
{
    TextColor = crColor;
}
 
void CImgButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    CRect rect = lpDrawItemStruct->rcItem;
    CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
    int nSaveDC = pDC->SaveDC();
    UINT state = lpDrawItemStruct->itemState;
    TCHAR strText[MAX_PATH + 1];
    ::GetWindowText(m_hWnd, strText, MAX_PATH);
 
    CBitmapButton::DrawItem(lpDrawItemStruct);
 
   // pDC->SetTextColor(TextColor);
   /* if (strText != NULL)
    {
        CFont* hFont = GetFont();
        CFont* hOldFont = pDC->SelectObject(hFont);
        CSize szExtent = pDC->GetTextExtent(strText, lstrlen(strText));
        CPoint pt(rect.CenterPoint().x - szExtent.cx / 2, rect.CenterPoint().y - szExtent.cy / 2);
        if (state & ODS_SELECTED)
        {
            pt.Offset(1, 1);
        }
        int nMode = pDC->SetBkMode(TRANSPARENT);
        if (state & ODS_DISABLED)
        {
            pDC->DrawState(pt, szExtent, strText, DSS_DISABLED, TRUE, 0, (HBRUSH)NULL);
        }
        else
        {
            pDC->DrawState(pt, szExtent, strText, DSS_NORMAL, TRUE, 0, (HBRUSH)NULL);
        }
        pDC->SelectObject(hOldFont);
        pDC->SetBkMode(nMode);
    }*/
 
    pDC->RestoreDC(nSaveDC);
}