CListCtrl 设置行高
CListCtrl 改变行高:
1. 表的修改
新建一个 MFC 类 CMyListCtrl,其基类为 CListCtrl,属性 Owner
Draw Fixed 设置为 TRUE;
添 加 变 量 CMyListCtrl m_List;MyListCtrl.h 文 件 里 , 添 加 变 量 int
m_nRowHeight;
2、重载 DrawItem()实现自绘,实现请参照以下代码。
手动添加消息宏 ON_WM_MEASUREITEM_REFLECT(),添加下面
的函数,实现修改行高。
void CMyListCtrl::MeasureItem(LPMEASUREITEMSTRUCT
lpMeasureItemStruct)
{
if (m_nRowHeight>0)
{
lpMeasureItemStruct->itemHeight = m_nRowHeight;
}
}
3、添加 ON_WM_MEASUREITEM,响应消息处理 OnMeasureItem()
void CMyListCtrl::OnMeasureItem(int nIDCtl,
LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CListCtrl::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
}
4 、 void CMyListCtrl::SetRowHeigt(int nHeight) // 高 置 行 高 ( 别 忘 了
在.h 里添加 void SetRowHeigt(int nHeight) ;)
{
m_nRowHeight = nHeight;
CRect rcWin;
GetWindowRect(&rcWin);