MFC 获取listcontrol中选中行是否在可视范围
代码
/// brief 判断当前选中行是否在可见
/// @param listTem 列表
///
bool T_IsSelRowVisible(CListCtrl& listTem)
{
int nCurSel = listTem.GetSelectionMark();
if (nCurSel < 0)
{
return false;
}
int nScrollPos = listTem.GetScrollPos(SB_VERT);
int nIndex = listTem.GetItemCount();
int nRangLimit = listTem.GetScrollLimit(SB_VERT);
int nLastLine = nScrollPos + (nIndex - nRangLimit);
if (nCurSel >= nScrollPos && nCurSel < nLastLine)
{
return true;
}
return false;
}
参考链接:https://blog.csdn.net/smalldown/article/details/44493487