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

📄 colorstatic.cpp

📁 vc++6.0开发网络典型应用实例导航 1. 本光盘提供了本书中所有的实例源程序文件。 2. 附录文件夹下是Winsock 函数参考以及错误码列表
💻 CPP
字号:
// ColorStatic.cpp : implementation file
//

#include "stdafx.h"
#include "Netmsg.h"
#include "ColorStatic.h"

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

//CColorStatic!! mainly used in the conversation dialog

CColorStatic::CColorStatic()
{
	Brush.CreateSolidBrush(RGB(0, 0, 0));
	m_Back = RGB(0, 0, 0);
	m_Fore = RGB(0, 0, 0);
}

CColorStatic::~CColorStatic()
{
}


BEGIN_MESSAGE_MAP(CColorStatic, CStatic)
	//{{AFX_MSG_MAP(CColorStatic)
	ON_WM_CTLCOLOR_REFLECT()
	ON_WM_PAINT()
	ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CColorStatic message handlers

void CColorStatic::SetColors(COLORREF crFore, COLORREF crBack)
{
	m_Back = crBack;
	m_Fore = crFore;
	Brush.DeleteObject();
	Brush.CreateSolidBrush(crBack);
	Invalidate();
}

HBRUSH CColorStatic::CtlColor(CDC* pDC, UINT nCtlColor) 
{
	pDC->SetBkColor(m_Back);
	pDC->SetTextColor(m_Fore);
	// TODO: Return a non-NULL brush if the parent's handler should not be called
	return (HBRUSH) Brush;
}

BOOL CColorStatic::OnEraseBkgnd(CDC* pDC) 
{
	RECT rect;
	GetClientRect(&rect);
	pDC->FillSolidRect(&rect, m_Back);
	return TRUE;
}

void CColorStatic::OnPaint() 
{
	CPaintDC dc(this);
	DWORD dwFormat = 0;
	RECT rectWnd;
	CString strText;
	CWnd* pWndParent = NULL;

	pWndParent = GetParent();

	if (pWndParent)
		dc.SelectObject (GetFont());

	GetWindowText(strText);
	GetClientRect(&rectWnd);
	dwFormat = DT_END_ELLIPSIS;
	dc.SetBkColor(m_Back);
	dc.SetTextColor(m_Fore);
	::DrawTextEx(dc.m_hDC, strText.GetBuffer(0), strText.GetLength(), &rectWnd, dwFormat, NULL);
	strText.ReleaseBuffer();
}

⌨️ 快捷键说明

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