SDC C-Project CF Review 프로그램
LYW
2021-08-10 ebfd7a15f5c7fe5d4cf9120a49b21f3cffd050f7
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
#include "stdafx.h"  
#include "GridCell.h"
#include "GridCtrl.h"
#include "GridCellButton.h"  
 
 
#ifdef _DEBUG  
#define new DEBUG_NEW  
#undef THIS_FILE  
static char THIS_FILE[] = __FILE__;
#endif  
 
IMPLEMENT_DYNCREATE(CGridCellButton, CGridCell)
    CGridCellButton::CGridCellButton(void)
{
    m_bPushing = FALSE;
}
 
CGridCellButton::~CGridCellButton(void)
{
}
 
BOOL CGridCellButton::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBkgnd /* = TRUE */)
{
    m_rect = rect;
    pDC->SetBkMode(TRANSPARENT);
    rect.DeflateRect(GetMargin(), 0);
    CFont* pOldFont = pDC->SelectObject(GetFontObject());
    pDC->DrawFrameControl(rect, DFC_BUTTON, m_bPushing ? DFCS_BUTTONPUSH | DFCS_PUSHED : DFCS_BUTTONPUSH);
    COLORREF ColorCurrent = pDC->GetTextColor();
    pDC->SetTextColor(::GetSysColor(COLOR_BTNTEXT));
    pDC->DrawText(GetText(), -1, rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
    pDC->SetTextColor(ColorCurrent);
    return TRUE;
}
 
void CGridCellButton::OnClick(CPoint PointCellRelative)
{
    m_bPushing = !m_bPushing;
    GetGrid()->InvalidateRect(m_rect);
}
 
void CGridCellButton::OnMouseLeave()
{
    m_bPushing = FALSE;
    GetGrid()->InvalidateRect(m_rect);
}