This is a rough and working implementation that relies on WM_CTLCOLOR message handling. Comments are in Italian but code is so stupid that I think even a spider could understand it.
License is LGPL
Header file
/** \file
\date $Date: 2007/01/10 17:09:43 $
\version $Revision: 1.1 $
*/
#ifndef __IPAQ_CLIENT_COLOR_BUTTON_H
#define __IPAQ_CLIENT_COLOR_BUTTON_H
#include <afxwin.h>
/** Subclass del pulsante standard che
permette una colorazione personalizzabile */
class CColorButton : public CButton
{
public:
CColorButton();
/** Specifica il colore in fase di creazione */
CColorButton(COLORREF color);
virtual ~CColorButton();
/** Ignoro il secondo parametro. Spero che arrivi
sempre il CTLCOLOR_BTN */
afx_msg HBRUSH CtlColor (CDC* pDC, UINT nCtlColor);
protected:
COLORREF m_Color;
CBrush m_BackBrush;
DECLARE_MESSAGE_MAP()
DECLARE_DYNAMIC(CColorButton)
};
#endif //__IPAQ_CLIENT_COLOR_BUTTON_H
Source file
/** \file
\date $Date: 2007/01/10 17:09:43 $
\version $Revision: 1.1 $
*/
#include "stdafx.h"
#include "ColorButton.h"
IMPLEMENT_DYNAMIC(CColorButton, CButton)
CColorButton::CColorButton()
{
m_Color = ::GetSysColor(COLOR_WINDOW);
m_BackBrush.CreateSolidBrush(m_Color);
}
CColorButton::CColorButton(COLORREF color) :
m_Color(color),
m_BackBrush(color)
{}
CColorButton::~CColorButton()
{}
BEGIN_MESSAGE_MAP(CColorButton, CButton)
ON_WM_CTLCOLOR_REFLECT()
END_MESSAGE_MAP()
HBRUSH CColorButton::CtlColor(CDC* pDC, UINT nCtlColor)
{
return (HBRUSH)m_BackBrush;
}
|
|
January '07 |
|
||||
| Mo | Tu | We | Th | Fr | Sa | Su |
| 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 | ||||
2006-2008 Giuseppe 'Cowo' Corbelli | Cowo's homepage | Cowo's photo page | Contact me | Back to top
Design by Andreas Viklund | Serendipity Template by Carl