CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    10

    Automatic Scrolling in CListBox

    I have a ListBox control in a dialog application, and I am programmatically adding lines to the listbox. I want the listbox to automatically scroll down as each new line is added by the program. I created the following function to do this:

    void CPVSMainDlg::ScrollWithIt(CListBox& lbox)
    {
    int limit;

    limit = lbox.GetScrollLimit(SB_VERT);

    lbox.SetScrollPos(SB_VERT, limit, TRUE);
    lbox.UpdateWindow();
    }

    Note: CPVSMainDlg is my main dialog box and I am passing the listbox to a member function that I created.

    This works partially in that the scrollbar on the listbox does go down to the bottom. The problem is that the listbox window itself does not actually scroll. I have tried many things and it is probably something simple that I am missing, but I just can't seem to get it to work. Anyone have any ideas??? Thanks in advance.


  2. #2
    Join Date
    May 1999
    Posts
    17

    Re: Automatic Scrolling in CListBox

    If you know the index of the added item - returned from AddString() - use SetTopIndex()

    Howard


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