Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
ColourEdit.h
////////////////////////////////////////////////////////////
//
// Class : CColourEdit
// Base Class : CEdit
// Author : Robert Cumming
// Date : August 2004
//
// Comment : Class used to create colour edit control dialog's
//
// version 1 : Initial Release Version
//
//
////////////////////////////////////////////////////////////
#pragma once
#include "afxwin.h"
class CColourEdit : public CEdit
{
public:
CColourEdit( void );
~CColourEdit( void );
void SetTextColour( COLORREF refRGB ); // set the colour of the text in the edit control
void SetBgColour( COLORREF refRGB ); // set the background colour of the edit control
protected:
DECLARE_MESSAGE_MAP()
private:
CBrush brush; // brush used for painting in the control
COLORREF rgb; // colour used for background
COLORREF text; // colour used for text
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); // paint the control
// afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
};
ColourEdit.cpp
////////////////////////////////////////////////////////////
//
// Class : CColourEdit
// Base Class : CEdit
// Author : Robert Cumming
// Date : August 2004
//
// Comment : Class used to create colour edit control dialog's
//
// version 1 : Initial Release Version
//
//
////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include ".\colouredit.h"
////////////////////////////////////////////////////////////
// Standard Constructor
////////////////////////////////////////////////////////////
CColourEdit::CColourEdit( void )
{
rgb = RGB(255,0,0);
text = RGB(0,0,0);
brush.CreateSolidBrush( rgb );
}
////////////////////////////////////////////////////////////
// Standard Destructor
////////////////////////////////////////////////////////////
CColourEdit::~CColourEdit( void )
{
}
BEGIN_MESSAGE_MAP(CColourEdit, CEdit)
ON_WM_CTLCOLOR_REFLECT()
END_MESSAGE_MAP()
////////////////////////////////////////////////////////////
// Set the colour of the text in the control
////////////////////////////////////////////////////////////
void CColourEdit::SetTextColour( COLORREF refRGB )
{
text = refRGB;
}
////////////////////////////////////////////////////////////
// Set the background colour of the edit control
////////////////////////////////////////////////////////////
void CColourEdit::SetBgColour( COLORREF refRGB )
{
rgb = refRGB;
}
////////////////////////////////////////////////////////////
// Routine to draw the colours of the control
////////////////////////////////////////////////////////////
HBRUSH CColourEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
pDC->SetTextColor ( text );
pDC->SetBkColor ( rgb );
brush.DeleteObject();
brush.CreateSolidBrush( rgb );
return brush;
}