#include "stdafx.h"
|
#include "CCustomCheckBox.h"
|
|
|
CCustomCheckBox::CCustomCheckBox()
|
: m_bgColor(RGB(255, 255, 255)), m_textColor(RGB(0, 0, 0))
|
{
|
m_brush.CreateSolidBrush(m_bgColor);
|
}
|
|
CCustomCheckBox::~CCustomCheckBox()
|
{
|
|
}
|
|
void CCustomCheckBox::SetBackgroundColor(COLORREF color)
|
{
|
m_bgColor = color;
|
if (m_brush.GetSafeHandle())
|
m_brush.DeleteObject();
|
m_brush.CreateSolidBrush(m_bgColor);
|
Invalidate();
|
}
|
|
void CCustomCheckBox::SetTextColor(COLORREF color)
|
{
|
m_textColor = color;
|
Invalidate();
|
}
|
|
void CCustomCheckBox::SetNotifyHwnd(HWND hWnd)
|
{
|
m_hNotifyWnd = hWnd;
|
}
|
|
void CCustomCheckBox::OnClicked()
|
{
|
BOOL bChecked = (GetCheck() == BST_CHECKED);
|
|
// Äã¿ÉÒÔ¶¨Òå×Ô¼ºµÄ×Ô¶¨ÒåÏûÏ¢
|
if (m_hNotifyWnd && ::IsWindow(m_hNotifyWnd)) {
|
::PostMessage(m_hNotifyWnd, WM_CHECKBOX_STATE_CHANGED, GetDlgCtrlID(), bChecked);
|
}
|
}
|
|
BEGIN_MESSAGE_MAP(CCustomCheckBox, CButton)
|
ON_WM_CTLCOLOR_REFLECT()
|
ON_CONTROL_REFLECT(BN_CLICKED, &CCustomCheckBox::OnClicked)
|
END_MESSAGE_MAP()
|
|
HBRUSH CCustomCheckBox::CtlColor(CDC* pDC, UINT /*nCtlColor*/)
|
{
|
pDC->SetBkMode(TRANSPARENT);
|
pDC->SetTextColor(m_textColor);
|
return (HBRUSH)m_brush.GetSafeHandle();
|
}
|