CGridCtrl 添加button (CGridCellButton类)
2015-10-23 21:09
841 查看
#ifndef __GRID_CELL_BUTTON__ #define __GRID_CELL_BUTTON__ #include "../GridCtrl_src/GridCell.h" class CGridCellButton : public CGridCell { friend class CGridCtrl; DECLARE_DYNCREATE(CGridCellButton) public: CGridCellButton(void); ~CGridCellButton(void); public: virtual BOOL Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBkgnd = TRUE); protected: virtual void OnClick(CPoint PointCellRelative); protected: CRect m_rect; BOOL m_bPushing; }; #endif
.cpp:
#include "stdafx.h" #include "../GridCtrl_src/GridCell.h" #include "../GridCtrl_src/GridCtrl.h" #include "GridCellButton.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif IMPLEMENT_DYNCREATE(CGridCellButton, CGridCell) CGridCellButton::CGridCellButton(void) { m_bPushing = FALSE; } CGridCellButton::~CGridCellButton(void) { } BOOL CGridCellButton::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBkgnd /* = TRUE */) { m_rect = rect; pDC->SetBkMode(TRANSPARENT); rect.DeflateRect(GetMargin(), 0); CFont* pOldFont = pDC->SelectObject(GetFontObject()); pDC->DrawFrameControl(rect, DFC_BUTTON, m_bPushing ? DFCS_BUTTONPUSH | DFCS_PUSHED : DFCS_BUTTONPUSH); COLORREF ColorCurrent = pDC->GetTextColor(); pDC->SetTextColor(::GetSysColor(COLOR_BTNTEXT)); pDC->DrawText(GetText(), -1, rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS); pDC->SetTextColor(ColorCurrent); return TRUE; } void CGridCellButton::OnClick(CPoint PointCellRelative) { m_bPushing = !m_bPushing; GetGrid()->InvalidateRect(m_rect); }
编译环境:vs2013 CGridCtrl版本:2.27
相关文章推荐
- iOS消息传递机制
- c++学习笔记(九):运算符重载进阶
- 迅雷是怎么下载的
- 黑马程序员——Java 基础:静态
- Andriod异步消息处理机制解析
- PPT基础与进阶
- 51nod 1099:任务执行顺序 贪心
- ftp 上传 文件 下载文件
- 51nod 1099:任务执行顺序 贪心
- find the most comfortable road(并差集,找差值最小的权值)
- Command(命令模式)
- POJ 2253 Frogger 最短路径 Floyed-Warshall算法
- 蓝懿ios 技术内容和心得 10。23
- java笔试题2--基础知识
- cocos2d-x-3.5 android 编译
- 网站字体渲染过程
- Python深入:Distutils安装包
- hdu5463
- 数组的常见操作
- copy-list-with-random-pointer