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

📄 coloredit.cpp

📁 ado 连接数据库,最简单的数据库编程 有利于初学者学习.
💻 CPP
字号:
// ColorEdit.cpp : implementation file
//

#include "stdafx.h"
#include "ColorEdit.h"

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

/////////////////////////////////////////////////////////////////////////////
// CColorEdit

CColorEdit::CColorEdit()
{
	
}

CColorEdit::~CColorEdit()
{
}

BEGIN_MESSAGE_MAP(CColorEdit, CEdit)
//{{AFX_MSG_MAP(CColorEdit)
ON_WM_NCPAINT()
ON_WM_PAINT()
ON_WM_CTLCOLOR_REFLECT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CColorEdit message handlers
HBRUSH CColorEdit::CtlColor(CDC* pDC, UINT nCtlColor) 
{
	COLORREF clr = RGB(223,0,35);
	//pDC->SetTextColor(clr);   //设置黑色的文本
	//clr = RGB(255,255,204);
	//pDC->SetBkColor(clr);     //设置红色的背景
//	m_bkBrush = ::CreateSolidBrush(clr);
	return m_bkBrush;  //作为约定,返回背景色对应的刷子句柄
}
void CColorEdit::OnHoverEnter()
{
	Redraw();
}

void CColorEdit::OnHoverLeave()
{
	Redraw();
}

void CColorEdit::Redraw()
{
	RedrawWindow(NULL,NULL,RDW_FRAME|RDW_INVALIDATE);
}

void CColorEdit::OnNcPaint() 
{
	CWindowDC DC(this);
	CRect Rect;
	GetWindowRect(&Rect);
   
	if (IsHover())
	{
		DC.Rectangle(0,0,Rect.Width(),Rect.Height());
	}
	else
	{
		DC.DrawEdge(CRect(0,0,Rect.Width(),Rect.Height()),EDGE_SUNKEN,BF_FLAT|BF_RECT);
	}

	//DC.BitBlt(570, 40,800, 500, &dcMem, 0, 0, SRCCOPY);
}
void CColorEdit::OnPaint()
{
	CPaintDC dc(this);
	CDC dcMem; 
	dcMem.CreateCompatibleDC(&dc);                          //创建与对话框dc兼容的内存dc
	//CRect rect;
	CRect Rect;
	GetWindowRect(&Rect);
	//GetClientRect();
	BITMAP bitMap;
	m_Bitmap.GetBitmap(&bitMap);
	CBitmap *pbmpOld=dcMem.SelectObject(&m_Bitmap);		    //将背景位图选入内存dc中
	dc.StretchBlt(0,0,Rect.Width(),Rect.Height(),&dcMem,0,0,bitMap.bmWidth,bitMap.bmHeight,MERGECOPY);
}

⌨️ 快捷键说明

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