Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Delphi XE7 VCL styles TListView flickers


This question is answered.


Permlink Replies: 4 - Last Post: Aug 30, 2016 4:16 AM Last Post By: Ede Csanádi
Ede Csanádi

Posts: 40
Registered: 10/9/06
Delphi XE7 VCL styles TListView flickers  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 28, 2016 2:14 PM
Hi!

I'm working with Delphi XE7 and recently added VCL styles option to my software.
There's a TListView which shows thumbnails. As folder is listed and the thumbnails are added, the thumbnails flicker until finished.
Tried both with and without double buffering, no difference. Works fine with double buffering enabled without styles.

Is there a way to fix this?

Thank you!
3delite
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: Delphi XE7 VCL styles TListView flickers  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 29, 2016 3:44 AM   in response to: Ede Csanádi in response to: Ede Csanádi
Ede Csanádi wrote:

Hi!

I'm working with Delphi XE7 and recently added VCL styles option to
my software. There's a TListView which shows thumbnails. As folder
is listed and the thumbnails are added, the thumbnails flicker until
finished. Tried both with and without double buffering, no
difference. Works fine with double buffering enabled without styles.

Is there a way to fix this?

If you are going to modify most of the content of a listview it usually
pays to block repainting of the control until your changes are
complete. You do this with a code block like this:

listview1.items.beginupdate;
try
...change the listview content here, show a hourglass mouse pointer
if this takes longer than a second or so
finally
listview1.items.endupdate;
end;


--
Peter Below
TeamB

Ede Csanádi

Posts: 40
Registered: 10/9/06
Re: Delphi XE7 VCL styles TListView flickers  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 29, 2016 8:15 AM   in response to: Peter Below in response to: Peter Below
Thank you for your suggestion, but I'm afraid it doesn't help. The thumbnails arrive from threads and I should see them appearing. As I wrote all is fine without styles, so the problem is related to styles. Is there an option to override something with style hooks?
BTW. in other case where I update a TListView sub item every second I tried adding BeginUpdate/EndUpdate but then not only the sub items flickered but the whole TListView.
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: Delphi XE7 VCL styles TListView flickers
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 29, 2016 8:37 AM   in response to: Ede Csanádi in response to: Ede Csanádi
Ede Csanádi wrote:

Thank you for your suggestion, but I'm afraid it doesn't help. The
thumbnails arrive from threads and I should see them appearing. As I
wrote all is fine without styles, so the problem is related to
styles. Is there an option to override something with style hooks?
BTW. in other case where I update a TListView sub item every second I
tried adding BeginUpdate/EndUpdate but then not only the sub items
flickered but the whole TListView.

The EndUpdate repaints the complete listview, so this is really only
useful if you modify many items in one operation.

Most VCL controls have a property named StyleElements. That allows you
some control over which parts of the control are drawn by the style
engine. Try to remove seClient from that set, perhaps it changes the
way the drawing happens.

Since i'm only writing Windows VCL applications and am of the firm
opinion that an application should honor the system style and not use
its own on Windows I have never investigated the way the style engine
works, sorry.

--
Peter Below
TeamB

Ede Csanádi

Posts: 40
Registered: 10/9/06
Re: Delphi XE7 VCL styles TListView flickers  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 30, 2016 4:16 AM   in response to: Peter Below in response to: Peter Below
Thank you very much, removing seClient and setting the background color manually works:

    //* Default values
    BackgroundColor := clWindow;
 
    Lister.DoubleBuffered := True;
    Lister.StyleElements := Lister.StyleElements - [seClient];
 
    LStyle := StyleServices;
    if LStyle.Enabled
    AND (TStyleManager.ActiveStyle.Name <> 'Windows')
    then begin
        //* Lister background color
        BackgroundColor := TStyleManager.ActiveStyle.GetStyleColor(scListView);
    end;
 
    Lister.Color := BackgroundColor;


One thing I noticed is that with styles the selection rectangle is missing. Just a normal fade is applied to the thumbnails. It's so with these modifications still, but no flicker any more and that's very good.
If I could keep the selection rectangle and the styled column header and the scroll bars it would be perfect.

Thanks!

Best regards
3delite
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02