Recent

Author Topic: TListBox flickers when scrolling (laz 1.4.0)  (Read 22882 times)

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: TListBox flickers when scrolling (laz 1.4.0)
« Reply #30 on: May 23, 2015, 12:33:38 am »
In the attachment, there is a modified version of your "extreme" demo, again with the "no-erase-background" listbox for comparison at the right - I don't see any flicker, in contrast to the standard listbox at the left.
« Last Edit: May 23, 2015, 12:35:39 am by wp »

ncs-sniper

  • Jr. Member
  • **
  • Posts: 53
Re: TListBox flickers when scrolling (laz 1.4.0)
« Reply #31 on: May 23, 2015, 03:04:34 am »
No, there is no flicker, but that does not mean it is ok. You simply cannot distinguish individual items, if you could, you would see it.
The problem as I see it is not that the background is cleared, the main problem, and I wrote it many times, is that the new item if first shown, and only after that the draw handler is called.
Therefore, when the background is cleared, it flickers because the newly shown item is first rendered empty (cleared) and then drawn in handler.
When you ignore the clearing, the program just move the list up or down and leaves the old item where it was, and that old item is then redrawn in the handler. If the old item visually differs from the newly drawn, it might again cause problems.

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: TListBox flickers when scrolling (laz 1.4.0)
« Reply #32 on: May 23, 2015, 10:24:41 am »
I am close to giving up on this one...

Quote
that the new item if first shown, and only after that the draw handler is called.
I read it as often as you wrote it, and as often I did not understand it. How can the new item be shown without calling the OnDrawItem handler?

The main question is: why does the CheckListbox behave correctly, but not the standard Listbox. The CheckListbox is just the standard listbox with a dedicated DrawItem method, just what we are doing.

[EDIT]
Looking into the sources of TCheckListbox I saw now that it implements a separate handler for the WM_EraseBackground message in the win32 widget set. I copied this handler into the standard listbox, now the "flicker" (as I call it - I never saw the one you are referring to) is gone, and compile your program (maybe you should rebuild the LCL).

Could you check this with your program?

In the attachment you'll find a zip file containing the patched "win32wschecklst.pp" and "win32wsstdctrls.pp" files. Copy them to the folder "lcl\interfaces\win32" of your Lazarus installation (rename the original ones in order to be able to restore them).
« Last Edit: May 23, 2015, 10:52:20 am by wp »

sin_dragan

  • Full Member
  • ***
  • Posts: 127
Re: TListBox flickers when scrolling (laz 1.4.0)
« Reply #33 on: May 24, 2015, 02:14:09 am »
@wp

+1 for example, very nice demonstration, thank you. I confirm that your example works (right listbox with no flickering). Also "fix" that you posted solves the problem.

I didn't need to rebuild lazarus, just recompile the project  :)
Windows 7 64 bit
Lazarus 1.4.1 (w/fixes) FPC 2.6.4 win32

ncs-sniper

  • Jr. Member
  • **
  • Posts: 53
Re: TListBox flickers when scrolling (laz 1.4.0)
« Reply #34 on: May 24, 2015, 02:25:56 am »
Quote
I read it as often as you wrote it, and as often I did not understand it. How can the new item be shown without calling the OnDrawItem handler?
Sorry, my mistake, I was confused by something else. Your patch really helps. I think this is the solution we are looking for. Good work!

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: TListBox flickers when scrolling (laz 1.4.0)
« Reply #35 on: May 24, 2015, 10:33:48 am »
Are you referring to the "win32.zip" a few postings above? This is what I would like to use because it is the code that works with TCheckListbox. BUT: It disables background erasing only for 1 column; so, if there are more columns I'd guess that there is flicker again.

ncs-sniper, could you check this? Set the ColumnCount of your listbox to 2 or greater and look for flicker again.

ncs-sniper

  • Jr. Member
  • **
  • Posts: 53
Re: TListBox flickers when scrolling (laz 1.4.0)
« Reply #36 on: May 24, 2015, 08:04:40 pm »
Yes, I was reffering to win32.zip.
Unfortunatelly, you are right, it flickers again when listbox is set to more than one column. And even the TCheckListBox flickers when set to more than one column.

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: TListBox flickers when scrolling (laz 1.4.0)
« Reply #37 on: May 25, 2015, 05:16:53 pm »
At the moment, I don't have an idea how this could be avoided: I commented the "(TCustomListBox(WindowInfo^.WinControl).Columns < 2)" condition from the "if", but this results in incorrect background painting in case of a partially filled multi-column listbox. The same happens after adding more conditions to the "if" in order to find a better handling for multi-column listboxes.

Since multi-column listboxes are not so popular I will propose the patched Win32WSStdCtrls as a workaround in the bugtracker. Not perfect, but better than nothing...

ncs-sniper

  • Jr. Member
  • **
  • Posts: 53
Re: TListBox flickers when scrolling (laz 1.4.0)
« Reply #38 on: May 26, 2015, 08:14:00 pm »
I completely agree. Till now, I wasn't even aware there is such property.  :D

ncs-sniper

  • Jr. Member
  • **
  • Posts: 53
Re: TListBox flickers when scrolling (laz 1.4.0)
« Reply #39 on: October 17, 2015, 11:03:10 pm »
Well, Lazarus 1.4.4 - it is happenning again, and now it cannot be fixed by interposer  >:(

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: TListBox flickers when scrolling (laz 1.4.0)
« Reply #40 on: October 18, 2015, 12:06:30 am »
Please post a demo where this flicker can be seen. This issue is very delicate and needs careful validation, the patch was partly reverted because we had cases which damaged standard painting of the listbox.

ncs-sniper

  • Jr. Member
  • **
  • Posts: 53
Re: TListBox flickers when scrolling (laz 1.4.0)
« Reply #41 on: October 18, 2015, 01:30:09 am »
I know previous fix had problems. I have nothing against reverting as long as it is not trading one bug for another.
What kind of demo should I post? The old test cases are still the same with the same results and the project mentioned in the first post is still alive. Here you have small video (quality is not good but the flickering is visible) https://www.dropbox.com/s/bqtnibrarsa4xju/flicker.mp4?dl=0.

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: TListBox flickers when scrolling (laz 1.4.0)
« Reply #42 on: October 18, 2015, 02:51:58 am »
I cannot debug a video...

The two demos attached to the old bug report (http://bugs.freepascal.org/view.php?id=28146) which had been showing massive flicker before applying the patch do not show flicker on my Win7 system with Laz 1.4.4.

So, I fear there's nothing I can do here.

Are you sure that your graphics driver is up to date and correct? Do you see the flicker on every computer?

ncs-sniper

  • Jr. Member
  • **
  • Posts: 53
Re: TListBox flickers when scrolling (laz 1.4.0)
« Reply #43 on: October 18, 2015, 03:38:10 am »
It works without problem when compiled in delphi or older laz. So I doubt it is related to system.
Of course you don't see it when there is this code:
Code: Pascal  [Select][+][-]
  1. if (WindowsVersion <= wvXP) or not ThemeServices.ThemesEnabled then
  2. ...
  3. else
  4.   (old rendering code from 1.4.2)
..it is not happenning on win7 even for me.

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: TListBox flickers when scrolling (laz 1.4.0)
« Reply #44 on: October 18, 2015, 10:54:33 am »
Please specify your operating system. XP? XP had to be excluded from the patch because of massive background painting issues which EVERYBODY sees.

 

TinyPortal © 2005-2018