Not getting the visible bottom index of the List Control in MFC?
-
Hello, In the list control, we have the function to get the top index in MFC, GetTopIndex(), but how can we have the index of the visible last row of the list control whether we scroll it or not? I am asking this question because I have to put a design on the bottom of the last row, even if I scroll it should stay on the last row's bottom. How should I refer to the last visible row programmatically? Thanks in advance.
-
Hello, In the list control, we have the function to get the top index in MFC, GetTopIndex(), but how can we have the index of the visible last row of the list control whether we scroll it or not? I am asking this question because I have to put a design on the bottom of the last row, even if I scroll it should stay on the last row's bottom. How should I refer to the last visible row programmatically? Thanks in advance.
If there's not a method for it loop from the first to the last item and when ItemIsVisible returns false break the loop the previous item was at the bottom.
-
Hello, In the list control, we have the function to get the top index in MFC, GetTopIndex(), but how can we have the index of the visible last row of the list control whether we scroll it or not? I am asking this question because I have to put a design on the bottom of the last row, even if I scroll it should stay on the last row's bottom. How should I refer to the last visible row programmatically? Thanks in advance.
The
CListCtrl
class provides the function GetCountPerPage()[^]:Quote:
Calculates the number of items that can fit vertically in the visible area of a list view control when in list view or report view.
Use that to calculate the index of the item visible on the bottom:
int MyListCtrl::GetBottomIndex() const
{
int n = GetTopIndex() + GetCountPerPage() - 1;
if (n >= GetItemCount())
n = GetItemCount() - 1;
return n;
} -
The
CListCtrl
class provides the function GetCountPerPage()[^]:Quote:
Calculates the number of items that can fit vertically in the visible area of a list view control when in list view or report view.
Use that to calculate the index of the item visible on the bottom:
int MyListCtrl::GetBottomIndex() const
{
int n = GetTopIndex() + GetCountPerPage() - 1;
if (n >= GetItemCount())
n = GetItemCount() - 1;
return n;
} -
If there's not a method for it loop from the first to the last item and when ItemIsVisible returns false break the loop the previous item was at the bottom.