Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CListCtrl How to insure a row & column are visible?

588 views
Skip to first unread message

M. Thomas Groszko

unread,
Nov 27, 2000, 3:00:00 AM11/27/00
to
I know an item and column that I want to be visible in a CListCtrl.
"EnsureVisible" allows me to scroll the item into view. How do I scroll the
column into view?

Thanks
Tom Groszko

Andy Hassall

unread,
Nov 28, 2000, 3:00:00 AM11/28/00
to

You could try scrolling the item into view with EnsureVisible(), then use
GetColumnWidth() to add up the widths of the columns up to the column you
want, then use Scroll() to scroll it across the desired amount.

--
Andy Hassall (an...@andyh.org) icq(5747695) http://www.andyh.org
http://www.andyh.uklinux.net/space - disk usage analysis tool

Tom Groszko

unread,
Nov 28, 2000, 3:00:00 AM11/28/00
to
Thanks That works great!

CListCtrl & ListCtrl = GetListCtrl();
ListCtrl.EnsureVisible(item, FALSE);
int ColumnIndex;
int StartColPosition = 0;
for (ColumnIndex = 0; ColumnIndex < column; ++ColumnIndex)
{ StartColPosition += ListCtrl.GetColumnWidth(ColumnIndex);
}
int CurrentScrollPosition = ListCtrl.GetScrollPos(SB_HORZ);
CSize ScrollAmount(StartColPosition - CurrentScrollPosition, 0);
ListCtrl.Scroll(ScrollAmount);


"Andy Hassall" <an...@andyh.org> wrote in message
news:7iq62todauqas81rq...@4ax.com...

Tom Groszko

unread,
Nov 28, 2000, 3:00:00 AM11/28/00
to
But this also seems to work

CListCtrl & ListCtrl = GetListCtrl();

CRect ItemRectangle;
ListCtrl.GetSubItemRect(item, column, LVIR_BOUNDS, ItemRectangle);
ListCtrl.Scroll(CSize( ItemRectangle.left,
ItemRectangle.top - 2*(ItemRectangle.bottom - ItemRectangle.top)));


GetSubItemRect is documented to return the rect of the subitem however it
seems to return
a rect relative to some current scroll position because when I want a
subitem prior to the
current scroll I can get negative xy values?????

"Tom Groszko" <gros...@rapistan.com> wrote in message
news:#03I1mVW...@cppssbbsa02.microsoft.com...

0 new messages