[go: up one dir, main page]

Menu

[r9]: / colorbtn.h  Maximize  Restore  History

Download this file

141 lines (91 with data), 3.0 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
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*************************************************************************
ColorBtn.h header file
CColorBtn: A control panel like color picker
by The Gremlin
Compatibility: Visual C++ 4.0 and up.
**************************************************************************/
#ifndef _COLORBTN_H_
#define _COLORBTN_H_
// In order to ease use, these values have been hard coded in colorbtn.rc
// This avoids the need for another header file.
#define IDD_COLORBTN (5100)
#define IDC_COLOR1 (5101)
#define IDC_COLOR20 (5120)
#define IDC_OTHER (5121)
// Utility class for the dialog
class CColorBtnDlg : public CDialog
{
// Construction
public:
static COLORREF colors[20];
static BYTE used[20];
CButton *parent;
int colorindex;
CColorBtnDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CColorBtnDlg)
enum { IDD = IDD_COLORBTN };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CColorBtnDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CColorBtnDlg)
virtual BOOL OnInitDialog();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
afx_msg void OnOther();
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
//}}AFX_MSG
void OnColor(UINT id);
void EndDialog( int nResult );
DECLARE_MESSAGE_MAP()
};
class CColorBtn : public CButton
{
// Construction
public:
CColorBtn();
// The selected color,set this variable to initialize the
// button's color and read to see the results
COLORREF currentcolor;
// Use Serialize to store the color table in a file. Call at the document's Serialize()
void Serialize( CArchive& ar );
// If using Serialize, call Reset to reinitialize the color table at OnNewDocument()
static void Reset();
// Use Load and Store to save/restore the color table to/from the registry
static BOOL Load();
static BOOL Store();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CColorBtn)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CColorBtn();
// Generated message map functions
protected:
//{{AFX_MSG(CColorBtn)
afx_msg void OnClicked();
//}}AFX_MSG
void DrawItem(LPDRAWITEMSTRUCT);
DECLARE_MESSAGE_MAP()
private:
// A number of pens and brushes needed to paint the button
CPen *oldpen;
CBrush *oldbrush;
CPen blackpen;
CPen dkgray;
CPen whitepen;
CBrush backbrush;
CBrush nullbrush;
CPen nullpen;
CColorBtnDlg dlg;
};
#endif