Lazarus
Programming => LCL => Topic started by: senglit on May 31, 2020, 08:30:25 pm
-
Hi all,
I have a TPageControl on my main form. It includes 5 TabSheets. In each TabSheet, there is a second level PageControl which have 3 to 5 TabSheets. In many of the sencond level TabSheet there is 1 TStringGrid.
I set the color of main form to clBlack, and set all of the color of StringGrids to clBlack.
There is a very serious flicker when I switch from one TabSheet to another. the canvas of StringGrid first is white, then it changes into black as I designed. It makes my application seems very silly.
I checked the property of StringGrids and ensured the DoubleBuffer are default as True. According to my knowledge, it should reduce the flicker very well. But it seems not working.
What should I do to avoid the flicker?
Thanks.
-
You could try
on the PageControl
PageControl.BeginBoundsUpdate;
then switch your forms..
and
go back to it.
PageControl.EndBoundsUpdate;
Like I said don't know if it will work for you..
Also, if you are repositioning items this is going to repaint lots of windows.
and in many cases you don't want to call Repaint because that is a direct route, call Update or invalidate at some point. that puts a delayed paint message in the que..
-
@senglit: Please post a zipped project so that we can see the issue ourselves. You should simplify your project as much as possible, but the flicker should remain, of course. Put the .pas, .lfm, .lpi and .lpr files into a common .zip which you can upload via "Attachements and other options" below the forum editor box. Do not include .exe, .ppu, .o, .res and other compiler-generated files, they are not needed and may make the upload exceed the file size limit of 250 KB.
-
If I recall correctly, then the same can be seen when switching SourceEditors in the IDE (assuming dark background).
Also from memory, I think the problem is, that switching pages, means
1) hiding the current page
2) showing the new page
In between the page control is painted without any page. And that is the white surface you see as flicker.
-
@senglit: Please post a zipped project so that we can see the issue ourselves.
Hi wp, there is a demo to show the flicker.
Some normal components are used, such as TEdit, TLabel, TStringGrid, TFloatSpinEdit, TPageControl and TTabSheet. All of the components are set as: backcolor->black, fontcolor->white.
The demo will do nothing but just show the components, and the flicker is serious now.
BTW: I use win10. I searched the forum and saw people said it's no way to change the backcolor,tablecolor,margincolor of TPageControl. That is a bad news to me. I don't want to see a white space between my level 1 pagecontrol and level 2 pagecontrol. Do you have a solution?
-
You could try
on the PageControl
PageControl.BeginBoundsUpdate;
then switch your forms..
and
go back to it.
PageControl.EndBoundsUpdate;
Like I said don't know if it will work for you..
Also, if you are repositioning items this is going to repaint lots of windows.
and in many cases you don't want to call Repaint because that is a direct route, call Update or invalidate at some point. that puts a delayed paint message in the que..
I'm not sure if I understand you correctly. For a certain TableSheet which has a StringGrid child, I added "TabSheet.BeginUpdateBounds;" in the OnEnter event and "TabSheet.EndUpdateBounds" in the OnExit event. But the flicker is still there.
-
I tried your project (tmp4) in Windows 7/64, FPC 3.0.4, Lazarus 2.0.8 - nothing special at changing tabs - no flickering seen.
-
I tried your project (tmp4) in macOS 10.14.6, FPC 3.0.4, Lazarus 2.0.6 - switched between all tabs and back again - no flickering to be seen at all.
-
TO WooBean & trev,
It's strange. I don't have WIN7/64 nor macOs with me, but I tried it on 3 computers (all of them are win10), and flicker show on every one.
Is it a Win10-Only problem?
-
Not only on Win10: it also flickers on Win7/64!
-
Video drivers?
-
The flicker is clearly visible on slower machines. @Martin_fr explained what causes the issue. I attach a windows only, pseudo solution, which will work, but the flickering should be fixed in LCL.
-
A possible patch that should prevent WM_ERASEBACKGROUND when a tab becomes inactive.
Lazarus quite recent trunk (+/- changes regarding TScrollBar, IntitalSetupDialog, Options.Environment options). FPC 3.0.4 (the mac os one) from svn + some mods.
Windows 10 Pro x64 (v. 1903 / 18362.418) and for occasional Linux tests, Manjaro (QT5 and GTK2)
-
Please put the patch on the bugtracker.
-
I just did one differently using the Lock windows in the Select Change message handler and it works perfectly...
Absolutely no flicker at all.
it did it in the TabcontrolParentMsghandler.
That sections receives both the Changing and changed messages..
I can forward a message to anyone that is interested... or put my suggestion in the bug tracker.
I do like the other suggestion too, might be less of a chance of window locking
EDIT:
Just tried that, yes that works just as well as the lock does with less risk!
Please summit Thank you.
:)
-
Martin_fr is right, the flicker can be seen during the designed time in the IDE.
Thanks to GetMem and BrunoK for your solutions, both work. Thanks to jamie, please contribute your suggestion in the bug tracker.
It seems Only TPageControl gets this problem. I built a self-made version TPageControl which composed of TImage and TPanel. And there is no flicker problem.