mfc ListControl 重绘网格线
来源:互联网 发布:物理名师课堂软件 编辑:程序博客网 时间:2024/06/06 08:47
.h文件
//网格线设置 [yal 2013.10.08]
int m_nGridStyle; //风格 PS_DASH,PS_SOLID,。。。
COLORREF m_GridColor; //颜色
int m_nGridWeigth; //粗度1,2,...
void setGridStyle(int nStyle);
void setGridWeight(int nWeight);
void setGridColor(COLORREF cr);
.cpp文件
CListCtrlCl::CListCtrlCl()
:m_nGridStyle(PS_SOLID)
,m_nGridWeigth(1)
,m_GridColor(RGB(255,255,255))
{
}
void CListCtrlCl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: 添加您的代码以绘制指定项
// 重绘网格线 [7/12/2013 dell]
const MSG *msg = GetCurrentMessage();
DefWindowProc( msg->message, msg->wParam, msg->lParam );
// Draw the lines only for LVS_REPORT mode
if( (GetStyle() & LVS_TYPEMASK) == LVS_REPORT )
{
// Get the number of columns
CClientDC dc(this );
//yal 2013.10.08画有颜色的线
CPen pen(m_nGridStyle,m_nGridWeigth,m_GridColor);
CPen* oldpen=dc.SelectObject(&pen);
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
int nColumnCount = pHeader->GetItemCount();
// The bottom of the header corresponds to the top of the line
RECT rect, rectCol;
pHeader->GetClientRect( &rect );
int top = rect.bottom;
// Now get the client rect so we know the line length and
// when to stop
GetClientRect( &rect );
if( !GetItemRect( 1, &rectCol, LVIR_BOUNDS ))
return;
int height1 = rectCol.bottom - rectCol.top;
// The border of the column is offset by the horz scroll
int borderx = 0 - GetScrollPos( SB_HORZ );
for( int i = 0; i < nColumnCount; i++ )
{
// Get the next border
borderx += GetColumnWidth( i );
// if next border is outside client area, break out
if( borderx >= rect.right ) break;
// Draw the line.
dc.MoveTo( borderx-1, top/*top*/);
dc.LineTo( borderx-1, height1+top+lpDrawItemStruct->itemID*height1/*nColumnCount*height1 + top*/);
}
// Draw the horizontal grid lines
// First get the height
if( !GetItemRect( 0, &rect, LVIR_BOUNDS ))
return;
int height = rect.bottom - rect.top;
GetClientRect( &rect );
int width = rect.right;
for(unsigned int i = 1; i <= lpDrawItemStruct->itemID+1; i++ )
{
dc.MoveTo( 0, top + height*i);
dc.LineTo( width, top + height*i );
}
dc.SelectObject(oldpen);
}
}
- mfc ListControl 重绘网格线
- ListControl控件绘制网格线
- MFC ListControl
- MFC ListCOntrol
- MFC ListControl
- MFC ListControl控件用法
- MFC ListControl用法
- MFC ListControl控件用法
- MFC ListControl如何使用
- MFC ListControl控件用法
- MFC ListControl控件用法
- MFC ListControl控件用法
- MFC ListControl如何使用
- MFC ListControl技巧汇总
- MFC ListControl用法总结
- MFC ListControl用法
- MFC ListControl用法
- MFC ListControl的使用
- 生成HTML静态化一个很有用的正则表达式的替换功能
- asp.net c#基于DEC的加密与解密
- 关于style.filter失效的可能情况之一
- .net 2.0与.net 4.0在母板页生成标签上的一个差异
- 给ff的专用的一个css hack
- mfc ListControl 重绘网格线
- IE6中多个绝对定位和相对定位重叠时z-index失效的问题
- .net2.0 Intelligencia.UrlRewriter在(iis6,iis7)伪静态的实现
- 扫盲:js改变css文件中display:none的设置
- ie9 img.complete
- 一个优秀的html文档头部
- 【转载】HTTP 错误 404.17 - Not Found 请求的内容似乎是脚本,因而将无法由静态文件处理程序来处理
- 一个简单的ie6和其它浏览器区分以及设置png24的透明
- 正常安装版win7修改host和ping生效的相关的设置