View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0005341 | JEDI VCL | 00 JVCL Components | public | 2010-09-29 18:01 | 2012-02-29 16:53 |
Reporter | tetardd | Assigned To | obones | ||
Priority | normal | Severity | feature | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | Daily / GIT | ||||
Target Version | Fixed in Version | 3.45 | |||
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. | ||||
|
Did you have a sample showing this problem? Kind regards Jens |
|
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. |
|
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). |
|
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; |
|
I'm sorry, but if would make our testing easier if you could provide the zipped sources of a sample application showing this |
2010-10-12 13:36
|
Demo JvScrollBox BeginUpdate.zip (562,382 bytes) |
|
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. |
|
Thanks, this is now integrated in SVN. Next time, please to try to respect the JVCL style guide, it will make integration easier. |
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 |