⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 colors.cpp

📁 VisualC高级编程技术精粹.rar
💻 CPP
字号:
// Colors.cpp : implementation file
//

#include "stdafx.h"
#include "SuperDigitalClock.h"
#include "Colors.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CColors dialog


CColors::CColors(CWnd* pParent /*=NULL*/)
	: CDialog(CColors::IDD, pParent)
{
	//{{AFX_DATA_INIT(CColors)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CColors::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CColors)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CColors, CDialog)
	//{{AFX_MSG_MAP(CColors)
	ON_BN_CLICKED(IDC_BUTTON_BACKGROUND_COLOR, OnButtonBackgroundColor)
	ON_BN_CLICKED(IDC_BUTTON_TEXT_COLOR, OnButtonTextColor)
	ON_BN_CLICKED(IDC_BUTTON_LINE_COLOR, OnButtonLineColor)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CColors message handlers

void CColors::OnButtonBackgroundColor() 
{
	// TODO: Add your control notification handler code here
	CColorDialog ColorDlg;
	if (ColorDlg.DoModal()==IDOK)
	{
		BackgroundColor = ColorDlg.GetColor(); // 取得背景颜色

		CDC* pDC; 
		pDC = GetDC();

		CBrush br;
		br.CreateSolidBrush(BackgroundColor);

		pDC->SelectObject(&br);
		pDC->Rectangle(200,25,270,45);

		ReleaseDC(pDC);
	}
}

void CColors::OnButtonTextColor() 
{
	// TODO: Add your control notification handler code here
	CColorDialog ColorDlg;
	if (ColorDlg.DoModal()==IDOK)
	{
		TextColor = ColorDlg.GetColor();

		CDC* pDC;
		pDC = GetDC();

		CBrush br;
		br.CreateSolidBrush(TextColor);

		pDC->SelectObject(&br);
		pDC->Rectangle(200,50,270,70);

		ReleaseDC(pDC);
	}
}

void CColors::OnButtonLineColor() 
{
	// TODO: Add your control notification handler code here
	CColorDialog ColorDlg;
	if (ColorDlg.DoModal()==IDOK)
	{
		LinesColor = ColorDlg.GetColor();
		CDC* pDC;
		pDC = GetDC();

		CBrush br;
		br.CreateSolidBrush(LinesColor);

		pDC->SelectObject(&br);
		pDC->Rectangle(200,75,270,95);

		ReleaseDC(pDC);
	}
}

void CColors::OnPaint() 
{
	// TODO: Add your message handler code here
	CPaintDC dc(this); // device context for painting
	CDC* pDC;
	pDC = GetDC();

	CBrush back_brush;
	CBrush line_brush;
	CBrush text_brush;

	back_brush.CreateSolidBrush(BackgroundColor);
	line_brush.CreateSolidBrush(LinesColor);
	text_brush.CreateSolidBrush(TextColor);

	pDC->SelectObject(&back_brush);
	pDC->Rectangle(200,25,270,45);
	pDC->SelectObject(&line_brush);
	pDC->Rectangle(200,75,270,95);
	pDC->SelectObject(&text_brush);
	pDC->Rectangle(200,50,270,70);

	ReleaseDC(pDC);

	// Do not call CDialog::OnPaint() for painting messages
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -