Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2026-01

TListBox in "virtual mode": feedback needed (especially from Delphi users).

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart

Hi,

I began to implement "virtual mode" for TCustomListBox (commit 6f438f77 of Lazarus main).
(Virtual mode is when Style := lbVirtual)
Associated issue:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/26229

Since I have no Delphi (anymore) to test how Delphi behaves, I based my implementation upon what I could find in the official Delphi documentation (which isn't very much).
ATM I have implemented OnData.
(And all this only on Windows.)

This is how it currently behaves currently if you set Style := lbVirtual:
- you need to implement OnData event (otherwise all items wiil be empty string).
- you need to set property Count (if you don't it will remain what the value of Items.Count was before setting lbVirtual
- reading Items[Index] will call the OnData event. This must provide the correct string. (I sincerely hope I interpreted this correctly, otherwise all of the rest is nonsensical)
- you cannot change an item via Items[Index] := SomeValue: nothing will happen.
- you cannot delete an item: nothing will happen.
- you cannot exchange items: nothing will happen.
- you cannot insert/add items: nothing will happen.
- you cannot clear the items: nothing will happen.
- you cannot sort the items: nothing will happen.
- in virtual mode the listbox is ownerdrawfixed, so if desired you can use OnDrawItem to draw the contenst of the listbox yourself

Quetsions I have:
1. Which of the above mentioned behaviours is NOT Delphi compatible? In particular: doest Delph give some error if you want to change/delete/insert/add items, or if OnData is nil?
2. I could not figure out when OnDataFind will be called: which method of TCustomListBox or it's Items would invoke OnDataFind? (I would suspect that this might be Items.IndexOf ?)
3. Am I correct in assuming that OnDataObject is invoked whenever you access (read) Items.Objects[Index] (and that his is also a read-ony operation)?
4. If you revert from lbVirtual to any other Style: what will be the content/state of Items?

Feel free to describe Delph incompatibilities (for what I've done so far, not things that haven't been implemented yet) in teh bugtracker (https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/26229). Feedback via this ML is welcome as well.

(Please do NOT compare the implementation to teh source code of Delphi, only do black-box testing: test the behaviour, not the implementation. This way our implementation remains clean.)i

Bart

Reply by email