-
Notifications
You must be signed in to change notification settings - Fork 0
/
ColorButton.cpp
49 lines (41 loc) · 954 Bytes
/
ColorButton.cpp
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
// ColorButton.cpp : implementation file
//
#include "stdafx.h"
#include "mapstruct.h"
#include "ColorButton.h"
void CColorButton::MeasureItem(LPMEASUREITEMSTRUCT lpMIS)
{
// all items are of fixed size
// must use LBS_OWNERDRAWVARIABLE for this to work
lpMIS->itemHeight = 20;
lpMIS->itemWidth = 40;
}
void CColorButton::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
CDC* pDC = CDC::FromHandle(lpDIS->hDC);
CBrush br(color);
pDC->FillRect(&lpDIS->rcItem, &br);
// pDC->FrameRect(&lpDIS->rcItem, &br);
}
void CColorButton::ChangeColor(void)
{
CColorDialog dlg(color, CC_FULLOPEN);
if (dlg.DoModal() == IDOK)
{
color = dlg.GetColor();
Invalidate(FALSE);
}
}
void CColorButton::ChangeColor(BYTE red, BYTE green, BYTE blue)
{
color = RGB(red,green,blue);
Invalidate(FALSE);
}
Srgbval CColorButton::toIGCColor(void)
{
Srgbval rgb;
rgb.red = GetRValue(color);
rgb.green = GetGValue(color);
rgb.blue = GetBValue(color);
return rgb;
}