1
votes

I had to replace an old MFCSharpGrid control with a CCheckListBox.

Now, after displaying the vertical scroll-bar for the list-box, it seems to send the correct events (the line up/down and page up/down) to the list's client area, and it allows mouse-wheel scrolling which isn't available with the scroll-bar hidden.

However, the scroll-bar is not updated itself: the thumb is not moving when scrolling the client area (not even in response to scrolls from the scroll-bar), and the thumb's size is not proportional to the page-size.

The list-box is created more or less like this:

m_grid.Create(LBS_HASSTRINGS | LBS_OWNERDRAWFIXED | LBS_NOTIFY, m_gridRect, this, IDC_GRID1);

Strings are added iteratively, and then we request displaying the scroll-bar like this:

m_grid.ShowScrollBar(SB_VERT, TRUE);

Trying to set the SCROLLINFO for min/max/page-size didn't solve the position update problem.

What am I missing here?

1

1 Answers

1
votes

You don't want to manually use ShowScrollBar. Delete that, and rather create the listbox with WS_VSCROLL style.

m_grid.Create(WS_VSCROLL | LBS_HASSTRINGS | LBS_OWNERDRAWFIXED | LBS_NOTIFY, m_gridRect, this, IDC_GRID1);

That way you get a vertical scrollbar automatically when the contents exceed the length of of the control.