MFC中listctrl控件如何冻结第一列?

2024-12-18 18:57:50
推荐回答(3个)
回答1:

void CFreezeLastRowListCtrl::FreezeLastItem()
{
if (m_AddedIndex != -1)
{
DeleteItem(m_AddedIndex);
}

int TopIndex = GetTopIndex();
int NumPerPage = GetCountPerPage();

m_AddedIndex = TopIndex + NumPerPage - 1;
if (m_AddedIndex < GetItemCount()-1)
{
CString Text = GetItemText(GetItemCount()-1,0);
InsertItem(m_AddedIndex,Text);
}
else
{
m_AddedIndex = -1;
}
}

void CFreezeLastRowListCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar*
pScrollBar)
{
SetRedraw(FALSE);
int nOldPos = GetScrollPos(SB_VERT);
CListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
nPos = GetScrollPos(SB_VERT);
if (SB_ENDSCROLL == nSBCode || nOldPos == nPos)
{
SetRedraw(TRUE);
return;
}

FreezeLastItem();
SetRedraw(TRUE);
}

回答2:

楼主解决了吗?能不能给我说下,QQ951107618

回答3:

加你q说吧!