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

📄 borderrect.cpp

📁 visual c++数字图像与图形处理中的光盘内容
💻 CPP
字号:
/////////////////////////////////////////////////////////////////////////////////
//
// BorderRect.cpp: implementation of the CBorderRect class.
//
////////////////////////////////////////////////////////////////////////////////
// 版权所有(2002)
// Copyright(2002)
// 编写者: 向世明
// Author: Xiang Shiming


#include "stdafx.h"
#include "BorderRect.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////


CBorderRect::CBorderRect()
{
}

CBorderRect::CBorderRect(int x,  int y,  int nWidth,  int nHeight)
{
	m_x = x;
	m_y = y;
	m_nWidth = nWidth;
	m_nHeight = nHeight;
	m_clrBack = RGB(255, 255, 255);
}

CBorderRect::~CBorderRect(){}



//(x, y)----最左上角点坐标
//宽度和高度
//bBackTransparent----背景是否透明
void CBorderRect::Draw(CDC* pDC, BOOL bBackTransparent)
{
	//先绘制边界
	CPen darkGrayPen(PS_SOLID,  1,  RGB(128, 128, 128));
	CPen* pOldestPen = pDC->SelectObject(&darkGrayPen);
	pDC->MoveTo(m_x,  (m_y + m_nHeight - 1));
	pDC->LineTo(m_x,  m_y);
	pDC->LineTo((m_x + m_nWidth - 1),  m_y);

	CPen blackPen(PS_SOLID,  1,  RGB(0, 0, 0));
	pDC->SelectObject(&blackPen);
	pDC->MoveTo((m_x + 1),  (m_y + m_nHeight- 2));
	pDC->LineTo((m_x + 1),  (m_y + 1));
	pDC->LineTo((m_x + m_nWidth - 2),  (m_y + 1));

	CPen grayPen(PS_SOLID,  1,  RGB(180, 180, 180));
	pDC->SelectObject(&grayPen);
	pDC->MoveTo((m_x + 1),  (m_y + m_nHeight - 2));
	pDC->LineTo((m_x + m_nWidth - 2),  (m_y + m_nHeight - 2));
	pDC->LineTo((m_x + m_nWidth - 2),  (m_y + 1));


	CPen whitePen(PS_SOLID,  1,  RGB(255, 255, 255));
	pDC->SelectObject(&whitePen);
	pDC->MoveTo(m_x,  (m_y + m_nHeight - 1));
	pDC->LineTo((m_x + m_nWidth - 1),  (m_y + m_nHeight - 1));
	pDC->LineTo((m_x + m_nWidth - 1),  m_y);
	pDC->SelectObject(pOldestPen);

	//背景透明与否
	if(!bBackTransparent)
	{
		//填充内区域
		CBrush newBrush(m_clrBack);
		CBrush* pOldBrush = pDC->SelectObject(&newBrush);
		CRect innerRect((m_x + 2), (m_y + 2), (m_x + m_nWidth - 2),  (m_y + m_nHeight - 2));

		pDC->FillRect(&innerRect, &newBrush);
		pDC->SelectObject(pOldBrush);
	}

}

void CBorderRect::SetSize(int x,  int y,  int nWidth,  int nHeight)
{
	m_x = x;
	m_y = y;
	m_nWidth = nWidth;
	m_nHeight = nHeight;
}

void CBorderRect::SetBkColor(COLORREF clrBack)
{
	m_clrBack = clrBack;
}

⌨️ 快捷键说明

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