CListCtrl with horizontal scroll
Dear experts,
I have an application that displays differences between two text files, something similar to comparing functionality of Visual Source Safe.
I am using a CListCtrl with two columns. Some of the lines I display may be very long. Such lines are not displayed in full, but part of them is replaced with "..."
Could you please tell me how I could have horizontal scrollbars in each column?
Also, how could I make both scrollbars work synchronously to make comparison easier, so that dragging one scroll would automatically move another one?
Thanks.
Re: CListCtrl with horizontal scroll
Quote:
Originally Posted by
dpreznik
I am using a CListCtrl with two columns. Some of the lines I display may be very long. Such lines are not displayed in full, but part of them is replaced with "..."
Could you please tell me how I could have horizontal scrollbars in each column?
Try CListCtrl::SetColumnWidth with LVSCW_AUTOSIZE parameter
Re: CListCtrl with horizontal scroll
I tried that, but in that case the columns have almost no width at all, only to squeeze there one character.
Re: CListCtrl with horizontal scroll
The CListCtrl doesn't offer this feature. you can't have a scrollbar inside a column.
An ownerdraw listcontrol and a lot of twiddly code could probably make this work, but.
you'll probably have noticed that most of the apps doing this kind of side by side comparison use 2 individual listcontrols and just synchronise them to display "the same" lines. Doing it that way is a lot simpler.
Re: CListCtrl with horizontal scroll
Could you please tell me how I can synchronized scrolls in case of 2 list controls? I would need to synchronized both vertical and horizontal scrolls. Thanks.
Re: CListCtrl with horizontal scroll
handle the WM_HSCROLL and WM_VSCROLL messages.
figure out what position you're at, then set the position for the other listcontrol.
you can also do it with just 1 vertical scrollbar.
in that case the right one has the scrollbar, do the same, trap WM_VSCROLL only on the right listcontrol. use a "virtual list" approach on the left one. basically the left list doesn't have stored lines, you make the listcontrol ask for contents as you go. the listcontrol basically has as many virtual items as it can display so it doesn't display a scrollbar.
If you wanna go this road, just make it work with a normal filled listcontrol on the left first, only handle WM_VSCROLL in the right list. Add the virtual list concept lateron.