-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathColorButton.cpp
More file actions
executable file
·90 lines (69 loc) · 1.75 KB
/
ColorButton.cpp
File metadata and controls
executable file
·90 lines (69 loc) · 1.75 KB
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
/*-----------------------------------------------------------------------------
Lua Studio
Copyright (c) 1996-2008 Michal Kowalski
-----------------------------------------------------------------------------*/
// ColorButton.cpp : implementation file
//
#include "stdafx.h"
#include "ColorButton.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CColorButton
CColorButton::CColorButton()
{
dx_ = ::GetSystemMetrics(SM_CXEDGE);
if (dx_ == 0)
dx_ = 2;
dy_ = ::GetSystemMetrics(SM_CYEDGE);
if (dy_ == 0)
dy_ = 2;
dx_ += 3;
dy_ += 3;
}
CColorButton::~CColorButton()
{
}
BEGIN_MESSAGE_MAP(CColorButton, CButton)
//{{AFX_MSG_MAP(CColorButton)
ON_WM_PAINT()
//}}AFX_MSG_MAP
ON_MESSAGE(BM_SETSTATE, OnSetState)
END_MESSAGE_MAP()
void CColorButton::SetColorRef(const COLORREF *color)
{
prgb_color_ = color;
if (m_hWnd)
Invalidate();
}
void CColorButton::PaintIt(int offset)
{
RECT rect;
GetClientRect(&rect);
rect.bottom -= dy_-offset;
rect.right -= dx_-offset;
rect.top += dy_+offset;
rect.left += dx_+offset;
CClientDC dc(this);
CBrush brush(::GetSysColor(COLOR_BTNTEXT));
dc.FillSolidRect(&rect,*prgb_color_);
dc.FrameRect(&rect,&brush);
}
/////////////////////////////////////////////////////////////////////////////
// CColorButton message handlers
void CColorButton::OnPaint()
{
// CPaintDC dc(this); // device context for painting
CButton::OnPaint(); // wywo³anie Default() - narysowanie guzika
int x= SendMessage(BM_GETSTATE,0,0);
PaintIt(x & BST_PUSHED ? 1 : 0);
}
afx_msg LRESULT CColorButton::OnSetState(WPARAM wParam, LPARAM /* lParam */)
{
CButton::Default();
PaintIt(wParam ? 1 : 0);
return 0;
}