#include "stdafx.h"
#include "WangHenGroupBox.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// WangHenGroupBox Version 1.0
//
//
// Thanks to: NT ALMOND's class CLable.
//
// Name Date Version Comments
// Jack Jin 2003-12-03 1.0 Origin
/////////////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNAMIC(WangHenGroupBox, CButton);
/////////////////////////////////////////////////////////////////////////////
// WangHenGroupBox
//////////////////////////////////////////////////////////////////////////
//
// Function: CXPGroupBox::CXPGroupBox
//
// Description: Default contructor
//
// Name Date Version Comments
// Jack Jin 2003-12-03 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
WangHenGroupBox::WangHenGroupBox()
{
m_strTitle = _T("");
m_clrBorder = ::GetSysColor(COLOR_3DSHADOW);
m_clrClientBackground = ::GetSysColor(COLOR_BTNFACE);
m_clrTitleText = ::GetSysColor(COLOR_WINDOWTEXT);
m_clrTitleBackground = ::GetSysColor(COLOR_BTNFACE);
m_nType = XPGB_FRAME;
m_dwAlignment = SS_LEFT;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: WangHenGroupBox::~WangHenGroupBox
//
// Description: Default destructor
// Note: Thanks John A. Johnson
//
// Name Date Version Comments
// Jack Jin 2003-12-03 1.0 Origin
// Jack Jin 2003-12-03 1.01 fix paint problem with help of John A. Johnson
//////////////////////////////////////////////////////////////////////////
WangHenGroupBox::~WangHenGroupBox()
{
}
BEGIN_MESSAGE_MAP(WangHenGroupBox, CButton)
//{{AFX_MSG_MAP(CXPGroupBox)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CXPGroupBox message handlers
//////////////////////////////////////////////////////////////////////////
//
// Function: CXPGroupBox::OnPaint
//
// Description: Handles all the drawing code for the label
//
// Name Date Version Comments
// Jack Jin 2003-12-03 1.0 Origin
//////////////////////////////////////////////////////////////////////////
void WangHenGroupBox::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect rectClient;
GetClientRect(rectClient);
// Defalte Rect
rectClient.DeflateRect(1, 1);
// Get Text Rect
CSize sizeText;
CRect rectText, rectFrame;
CRect rectTitle, rectContent;
CFont *pOldFont = dc.SelectObject(&m_font);
// get Text if need
if (m_strTitle.IsEmpty())
{
GetWindowText(m_strTitle);
if (!m_strTitle.IsEmpty())
m_strTitle = _T(" ") + m_strTitle + _T(" ");
}
if (!m_strTitle.IsEmpty())
{
sizeText = dc.GetTextExtent(m_strTitle);
}
else
{
sizeText.cx = 0;
sizeText.cy = 0;
}
if (m_nType == XPGB_FRAME) // Frame style
{
// Calculate Text Rect
switch (m_dwAlignment)
{
case SS_LEFT:
rectText.top = rectClient.top;
rectText.left = rectClient.left + 10;
rectText.bottom = rectText.top + sizeText.cy;
rectText.right = rectText.left + sizeText.cx;
break;
case SS_CENTER:
rectText.top = rectClient.top;
rectText.left = rectClient.left + (rectClient.Width() - sizeText.cx) / 2;
rectText.bottom = rectText.top + sizeText.cy;
rectText.right = rectText.left + sizeText.cx;
break;
case SS_RIGHT:
rectText.top = rectClient.top;
rectText.right = rectClient.right - 10;
rectText.bottom = rectText.top + sizeText.cy;
rectText.left = rectText.right - sizeText.cx;
break;
}
// Calculate Frame rect
rectFrame.left = rectClient.left;
rectFrame.top = rectClient.top + sizeText.cy / 2;
rectFrame.right = rectClient.right;
rectFrame.bottom = rectFrame.top + rectClient.Height() - sizeText.cy / 2;
// Draw Frame border
CPen penFrame;
CBrush brushBKFrame(m_clrTitleBackground);
penFrame.CreatePen(PS_SOLID, 1, m_clrBorder);
CPen* pOldPen = dc.SelectObject(&penFrame);
CBrush* pOldBrush = (CBrush*)dc.SelectStockObject(NULL_BRUSH);
dc.RoundRect(rectFrame, CPoint(10, 10));
dc.SelectObject(pOldPen);
dc.SelectObject(pOldBrush);
dc.IntersectClipRect(rectText);
dc.FillSolidRect(rectText, m_clrTitleBackground);
}
else // Windows Style
{
// Calculate Title size
rectTitle.top = rectClient.top;
rectTitle.left = rectClient.left;
rectTitle.right = rectClient.right;
rectTitle.bottom = rectClient.top + sizeText.cy + 4;
// Draw Title round rect
CPen penFrame;
CBrush brushBKTitle(m_clrTitleBackground);
CBrush brushBKContent(m_clrClientBackground);
penFrame.CreatePen(PS_SOLID, 1, m_clrBorder);
CPen* pOldPen = dc.SelectObject(&penFrame);
CBrush* pOldBrush = dc.SelectObject(&brushBKTitle);
dc.RoundRect(rectClient, CPoint(10, 10));
dc.SelectObject(pOldBrush);
// Draw content area
rectContent.left = rectClient.left;
rectContent.top = rectClient.top + sizeText.cy + 4;
rectContent.right = rectClient.right;
rectContent.bottom = rectContent.top + rectClient.Height() - sizeText.cy - 4;
pOldBrush = dc.SelectObject(&brushBKContent);
dc.Rectangle(rectContent);
dc.SelectObject(pOldPen);
dc.SelectObject(pOldBrush);
// Calculate Text Rect
switch (m_dwAlignment)
{
case SS_LEFT:
rectText.top = rectTitle.top + 2;
rectText.left = rectTitle.left + 2;
rectText.bottom = rectText.top + sizeText.cy;
rectText.right = rectText.left + sizeText.cx;
break;
case SS_CENTER:
rectText.top = rectTitle.top + 2;
rectText.left = rectTitle.left + (rectTitle.Width() - sizeText.cx) / 2;
rectText.bottom = rectText.top + sizeText.cy;
rectText.right = rectText.left + sizeText.cx;
break;
case SS_RIGHT:
rectText.top = rectTitle.top + 2;
rectText.right = rectClient.right - 2;
rectText.bottom = rectText.top + sizeText.cy;
rectText.left = rectText.right - sizeText.cx;
break;
}
}
COLORREF clrOldText = dc.SetTextColor(m_clrTitleText);
UINT nMode = dc.SetBkMode(TRANSPARENT);
dc.DrawText(m_strTitle, &rectText, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOCLIP); //DT_END_ELLIPSIS);
// restore DC
dc.SetBkMode(nMode);
dc.SetTextColor(clrOldText);
dc.SelectObject(pOldFont);
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CXPGroupBox::Create
//
// Description: Modify the groupbox windows style
//
// Name Date Version Comments
// Jack Jin 2003-12-03 1.0 Origin
//////////////////////////////////////////////////////////////////////////
BOOL WangHenGroupBox::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
dwStyle |= BS_ICON;
return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CXPGroupBox::PreCreateWindow
//
// Description: Modify the groupbox windows style
//
// Name Date Version Comments
// Jack Jin 2003-12-03 1.0 Origin
//////////////////////////////////////////////////////////////////////////
BOOL WangHenGroupBox::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
cs.style |= BS_ICON;
return CButton::PreCre
wanghencsdn
- 粉丝: 6
- 资源: 17
最新资源
- 当当网畅销榜数据24小时,近七天,近一个月,近一年(未处理).zip
- (178163814)(课程实践)MATLAB车道线检测定位.7z
- 汇川AM401系列程序 汇川AM403程序,搭配汇川总线伺服,汇川IT7070系列触摸屏 全自动N95口罩机 大型程序近20000步,凸轮同步控制,凸轮曲线应用,超声波焊接机控制,放卷张力控制,封边轴
- 基于springboot的在线智慧考公系统源码(java毕业设计完整源码).zip
- 基于springboot的在线考试系统源码(java毕业设计完整源码).zip
- Android studio成品源码项目日历备忘录记事本,该日历备忘录app实现了日历查看,添加备忘录,闹钟提醒,删除备忘录等功能,适合新手学习,数据库sqlite 程序开开发发,全网回复最快,效率
- 基于springboot的在线考试系统-源码(java毕业设计完整源码+LW).zip
- 基于springboot的在线问诊系统的设计与实现源码(java毕业设计完整源码).zip
- 基于springboot的在线项目管理与任务分配中的应用源码(java毕业设计完整源码).zip
- Wireshark-win64-4.0.6
- 基于springboot的垃圾分类回收管理系统源码(java毕业设计完整源码).zip
- 全国各省市榜单数据可视化教程.zip
- (21986618)基于深度学习识别人脸性别和年龄
- 基于springboot的城市公交管理系统源码(java毕业设计完整源码).zip
- 基于javaee的超市外卖系统的设计与实现源码(java毕业设计完整源码+LW).zip
- (175757424)大麦抢票-BP全自动抢购教程+注意事项.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈