|
// DColors.cpp : implementation file
//
#include "stdafx.h"
#include "CSSSandbox.h"
#include "DColors.h"
#include "afxdialogex.h"
// DColors dialog
IMPLEMENT_DYNAMIC(DColors, CDialogEx)
DColors::DColors(CWnd* pParent /*=NULL*/)
: CDialogEx(DColors::IDD, pParent)
{
}
DColors::~DColors()
{
}
void DColors::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_BGCOLOR_BOX, bgColorBox);
DDX_Control(pDX, IDC_FGCOLOR_BOX, fgColorBox);
}
BEGIN_MESSAGE_MAP(DColors, CDialogEx)
ON_WM_CTLCOLOR()
ON_STN_CLICKED(IDC_BGCOLOR_BOX, &DColors::OnStnClickedBgcolorBox)
ON_STN_CLICKED(IDC_FGCOLOR_BOX, &DColors::OnStnClickedFgcolorBox)
END_MESSAGE_MAP()
// DColors message handlers
BOOL DColors::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: Add extra initialization here
CreateBrushes();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void DColors::CreateBrushes()
{
if ((HBRUSH)bgColorBr != NULL)
bgColorBr.DeleteObject();
bgColorBr.CreateSolidBrush(bgColor);
if ((HBRUSH)fgColorBr != NULL)
fgColorBr.DeleteObject();
fgColorBr.CreateSolidBrush(fgColor);
}
HBRUSH DColors::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
int ctrlID = pWnd->GetDlgCtrlID();
if (ctrlID == IDC_BGCOLOR_BOX)
return bgColorBr;
else if (ctrlID == IDC_FGCOLOR_BOX)
return fgColorBr;
return hbr;
}
void DColors::OnStnClickedBgcolorBox()
{
CColorDialog dlg(bgColor,CC_FULLOPEN|CC_RGBINIT|CC_SOLIDCOLOR);
if (dlg.DoModal() != IDOK)
return;
bgColor = dlg.GetColor();
CreateBrushes();
Invalidate();
}
void DColors::OnStnClickedFgcolorBox()
{
CColorDialog dlg(fgColor,CC_FULLOPEN|CC_RGBINIT|CC_SOLIDCOLOR);
if (dlg.DoModal() != IDOK)
return;
fgColor = dlg.GetColor();
CreateBrushes();
Invalidate();
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.