CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2009
    Posts
    27

    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.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: CListCtrl with horizontal scroll

    Quote Originally Posted by dpreznik View Post
    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
    Victor Nijegorodov

  3. #3
    Join Date
    Aug 2009
    Posts
    27

    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.

  4. #4
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    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.

  5. #5
    Join Date
    Aug 2009
    Posts
    27

    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.

  6. #6
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured