0

Not sure if this is possible, but I have two CListBox controls which I need to vertically sync, but the controls may have different amount of data in them as well as each row may be of different heights. I want it such that no matter what is in each control, when I get to the top or bottom of one, I get to the same top or bottom of the other.

To do this right, I need to vertically scroll the items such that they don't necessarily align on an item boundary. Like the following example:

Showing 2 things that can be done and 1 that I need to be done

Left side shows the top of row one, the middle shows the top of row two. The right image shows a partial of row 1, which is what I need.

Is this possible, or am I going to have to do a major refactor requiring that I swap the controls out with something else? (definitely not preferable due to potential risk)

Oh, and before anyone asks why it was done like this, the answer is legacy.

I'm still looking into this, but if the control can't be forced to to this, might there be a workaround where I could have some sort of virtual CListBox which I could possibly BitBlt from, or would that entail more work then swapping out controls? Is there a better way?

Perhaps I could encapsulate the control in another window which would be able to have a larger view and clip that view to what I want to see?

Jabberwocky
  • 48,281
  • 17
  • 65
  • 115
Adrian
  • 10,246
  • 4
  • 44
  • 110
  • Oh, and we've got our first unhelpful downvote/close vote. You win the internet my friend. – Adrian Nov 22 '17 at 18:25
  • You can select whetever you like in the list box and ensure it is visible. But it is up to you to handle the logic. When you select one item in one listbox, follow your logic to update the second. Just becare you don't get stuck in a loop of the second being updated and thus trying to update the first. So you need a flag. – Andrew Truckle Nov 22 '17 at 18:32
  • It is also not fully clear what you want to do. It also sounds like you want to set the vertical scroll step ratio in one to be relative to the other. – Andrew Truckle Nov 22 '17 at 18:33
  • I think you have the down vote because you have not showed what you have tried nor attempted to visually explain what you are trying to do. – Andrew Truckle Nov 22 '17 at 18:34
  • @AndrewTruckle How do I position the viewed top to be not located on an item boundary. I only see `int CListBox::SetTopIndex(int nIndex)`. – Adrian Nov 22 '17 at 18:34
  • Can't you calculate it? If you know how many rows fit the visual part of the display, then why can't you offset the top index as needed. Eg: if you want index 20 at the bottom, and you can only see 10 at a time, set top index to 11. – Andrew Truckle Nov 22 '17 at 18:36
  • @AndrewTruckle From what I've seen of a CListBox control, it allows vertical scrolling in (apparently) indivisible rows. i.e. I do not know how to get the top item to only be partially shown, since `nIndex` refers to a row number, not an arbitrary window position. – Adrian Nov 22 '17 at 18:39
  • Then maybe you should possibly look at the scrollbar properties? I can't suggest anymore myself. Sorry. – Andrew Truckle Nov 22 '17 at 18:53
  • I'm afraid this is not possible with the standard list view control. I think you need to rewrite this more or less from scratch. – Jabberwocky Nov 22 '17 at 19:38
  • @MichaelWalz, not exactly what I'm looking to hear. You don't think it would be possible to have an encapsulating window to be able to do this? I'm thinking that it could forward messages to the encapsulated window, and somehow move the encapsulated window when positioning to manage the points between the rows. Just that I don't know how difficult this would be. ☹️ – Adrian Nov 22 '17 at 19:44
  • 1
    Can you use a **ListView** control instead? ListView allows for pixel-precise scroll positioning. – zett42 Nov 22 '17 at 21:54

0 Answers0