Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0005341 [JEDI VCL] 00 JVCL Components feature always 2010-09-29 18:01 2012-02-29 16:53
Reporter tetardd View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version Daily / GIT
Summary 0005341: Add BeginUpdate/EndUpdate to TJvScrollBox
Description TJvScrollBox are meant to receive controls, sometimes these are buid at run-time and that can have ugly flickering effect on the scroll box while it's being populated.

It would be nice to have BeginUpdate/EndUpdate procedures added to it that send a wm_SetRedraw message to block refreshing the display.

Should also apply to TPanel, if there is such a thing as a TjvPanel.




Additional Information
Private
    FLockCount : Integer;

...

Procedure TJvScrollBox.BeginUpdate;
Begin
     Inc(FLockCount);
     If FLockCount = 1 Then
          SendMessage(Handle, wm_SetRedraw, Ord(False), 0);
End;

Procedure TJvScrollBox.EndUpdate;
Begin
     Dec(FLockCount);
     If FLockCount = 0 Then
     Begin
         SendMessage(Handle, wm_SetRedraw, Ord(True), 0);
         Refresh;
     End;
End;
Tags No tags attached.
Attached Files zip file icon Demo JvScrollBox BeginUpdate.zip [^] (562,382 bytes) 2010-10-12 13:36

- Relationships

-  Notes
(0017727)
jfudickar (developer)
2010-09-30 00:09

Did you have a sample showing this problem?

Kind regards
Jens
(0017728)
tetardd (reporter)
2010-09-30 10:30

My project is too big and confidential to send to you to illustrate it.

However, it can be easy to simulated:

Procedure TForm1.Button1Click(Sender : TObject);
Var
   i : Integer;
Begin
     { Remove remark to fix the flicker: }
     // SendMessage(ScrollBox1.Handle, wm_SetRedraw, Ord(False), 0);
     For i := 1 To 1000 Do
     Begin
          With TLabel.Create(Self) Do
          Begin
               Parent := ScrollBox1;
               Left := 0;
               Top := i * 20;
          End;
          // Simulate lengthy configuring of the newly created TLabel control:
          Sleep(250);
     End;
     { Remove remarks to fix the flicker: }
     // SendMessage(ScrollBox1.Handle, wm_SetRedraw, Ord(True), 0);
     // ScrollBox1.Refresh;
End;

When I observed it, I googled for the problem to find a suggested answer and found that some others encountered it too and had to use the trick proposed above in their code (SendMessage with wm_SetRedraw, as shown above) so I thought that the components itself should handle the locking of refresh as suggested, using a BeginUpdate/EndUpdate mechanism (as is found in TListView).

NB: In essence, this should have been part of the VCL in the first place but Borland/CodeGear/Embarcadero didn't do a good job with that.
(0017730)
tetardd (reporter)
2010-09-30 15:42

OK, I found a problem with my suggestion. If your scroll box contains VCL controls, it works well but if it contains frames, they are not repainted, which is worse than the flicker so I suggest either ditch this suggestion and let's live with the flicker or somebody might know a way to repaint the frames fully (calling Invalidate/refresh for the scroll box or frames does not work).
(0017731)
tetardd (reporter)
2010-09-30 16:29

Found a possible solution: instead of calling Refresh after sending the wm_SetRedraw message, do:

RedrawWindow(ScrollBox1.handle, Nil, 0, RDW_ERASE or RDW_INVALIDATE or
 RDW_FRAME or RDW_ALLCHILDREN);

The EndUpdate would then look like:

Procedure TJvScrollBox.EndUpdate;
Begin
     Dec(FLockCount);
     If FLockCount = 0 Then
     Begin
         SendMessage(Handle, wm_SetRedraw, Ord(True), 0);
         RedrawWindow(ScrollBox1.handle, Nil, 0, RDW_ERASE or RDW_INVALIDATE or
            RDW_FRAME or RDW_ALLCHILDREN);
     End;
End;
(0017841)
obones (administrator)
2010-10-08 16:40

I'm sorry, but if would make our testing easier if you could provide the zipped sources of a sample application showing this
(0017877)
tetardd (reporter)
2010-10-12 13:38

I uploaded a demo. Simply run it and execute it with and without the check box ticked (to use or not a BeginUpdate/EndUpdate mechanism). Also in the zip file is my proposed changes to TJvScrollBox that was used to create the demo.
(0018060)
obones (administrator)
2010-11-09 15:10

Thanks, this is now integrated in SVN.
Next time, please to try to respect the JVCL style guide, it will make integration easier.

- Issue History
Date Modified Username Field Change
2010-09-29 18:01 tetardd New Issue
2010-09-30 00:09 jfudickar Note Added: 0017727
2010-09-30 00:09 jfudickar Status new => feedback
2010-09-30 10:30 tetardd Note Added: 0017728
2010-09-30 15:42 tetardd Note Added: 0017730
2010-09-30 16:29 tetardd Note Added: 0017731
2010-10-08 16:40 obones Note Added: 0017841
2010-10-12 13:36 tetardd File Added: Demo JvScrollBox BeginUpdate.zip
2010-10-12 13:38 tetardd Note Added: 0017877
2010-11-09 15:10 obones Note Added: 0018060
2010-11-09 15:10 obones Status feedback => resolved
2010-11-09 15:10 obones Fixed in Version => Daily / SVN
2010-11-09 15:10 obones Resolution open => fixed
2010-11-09 15:10 obones Assigned To => obones
2012-02-29 16:53 obones Fixed in Version Daily / SVN => 3.45


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker