Reduce flickering on ListView resize
I use a TNTListView to display some information. It's set to vsReport and it shows column headers.
I set AutoSize to false to all the colums because I noticed that it's not working properly and I'm doing the column resizing programatically in the OnResize form event (in the listview event doesn't work).
I divide ListView.ClientWidth to the Columns.Width (between Columns.BeginUpdate and Columns.EndUpdate).
The problem is the ListView is flickering badly when I resize the form, especialy when I reduce it, because the horizontal scrollbar appears for a split second.
1. I can try to disable the horizontal scrollbar during form resizing (or completely). But I tried every fix found here and on the first 5 Google pages, NOTHING worked.
2. Disable the listview anchors on form and resize it manually in the OnResize form event. The problem is I need a way to completely stop the listview from updating its interface (not just items or columns). This way it will update only after all the modifications are done but still change ListView.ClientWidth internally so I can use it to resize the columns. But I haven't found such way...
3. Use other component. But I prefer to do this ONLY as a last,...last resort.
Can you please help me find a better solution..?
July 10th, 2013, 08:46 AM
Try setting the containing form's doublebuffered property to true.
July 10th, 2013, 10:19 AM
But I already tried it in form.oncreate (is on for months now) and I don't see any improvement with the listview, only with other components like BitBtn,SpeedButton...
And listview.doublebuffered has no effect also.
Oh, btw, sorry for not mentioning, I use Delphi 7.
July 10th, 2013, 01:03 PM
Possibly if you handle the WM_ERASEBKGRND message, flickering can be controlled. You can derive a new TNTListView component, use the source here as a guide on how to do so.
July 10th, 2013, 10:58 PM
You mean devising a new component with a sort of "manual made DoubleBuffered"...?
That's a lot of work for just improving the resize...
I'm thinking about keeping the image of the listview in a TBitMap and painting it on the listview canvas when it's necessary. Is it ok?
The tricky part is how to know exactly when is necessary or not...