Recent

Author Topic: Very serious flicker when StringGrids on PageControl  (Read 1408 times)

senglit

  • Jr. Member
  • **
  • Posts: 56
Very serious flicker when StringGrids on PageControl
« 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.
I use Win10 + Lazarus 2.0.10 + FPC 3.2.0. All 64bit.

jamie

  • Hero Member
  • *****
  • Posts: 3524
Re: Very serious flicker when StringGrids on PageControl
« Reply #1 on: June 01, 2020, 12:32:57 am »
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..
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 7536
Re: Very serious flicker when StringGrids on PageControl
« Reply #2 on: June 01, 2020, 12:45:51 am »
@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.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6608
  • Debugger - SynEdit - and more
    • wiki
Re: Very serious flicker when StringGrids on PageControl
« Reply #3 on: June 01, 2020, 01:33:14 am »
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

  • Jr. Member
  • **
  • Posts: 56
Re: Very serious flicker when StringGrids on PageControl
« Reply #4 on: June 01, 2020, 06:13:07 am »
@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?
I use Win10 + Lazarus 2.0.10 + FPC 3.2.0. All 64bit.

senglit

  • Jr. Member
  • **
  • Posts: 56
Re: Very serious flicker when StringGrids on PageControl
« Reply #5 on: June 01, 2020, 06:22:36 am »
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.
« Last Edit: June 01, 2020, 06:36:02 am by senglit »
I use Win10 + Lazarus 2.0.10 + FPC 3.2.0. All 64bit.

WooBean

  • Jr. Member
  • **
  • Posts: 91
Re: Very serious flicker when StringGrids on PageControl
« Reply #6 on: June 01, 2020, 08:03:44 am »
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.
Win7/64, Lazarus 1.8 win64-win64, FPC 3.0.4

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 938
  • Former Delphi 1-7, 10.2 User
Re: Very serious flicker when StringGrids on PageControl
« Reply #7 on: June 01, 2020, 08:41:46 am »
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.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r46876, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

senglit

  • Jr. Member
  • **
  • Posts: 56
Re: Very serious flicker when StringGrids on PageControl
« Reply #8 on: June 01, 2020, 08:47:18 am »
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?
I use Win10 + Lazarus 2.0.10 + FPC 3.2.0. All 64bit.

TraumTaenzerDieter

  • New Member
  • *
  • Posts: 26
Re: Very serious flicker when StringGrids on PageControl
« Reply #9 on: June 01, 2020, 09:03:55 am »
Not only on Win10: it also flickers on Win7/64!
« Last Edit: June 01, 2020, 09:11:44 am by TraumTaenzerDieter »

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 938
  • Former Delphi 1-7, 10.2 User
Re: Very serious flicker when StringGrids on PageControl
« Reply #10 on: June 01, 2020, 09:29:48 am »
Video drivers?
o Lazarus v2.1.0 r63871, FPC v3.3.1 r46876, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

GetMem

  • Hero Member
  • *****
  • Posts: 3757
Re: Very serious flicker when StringGrids on PageControl
« Reply #11 on: June 01, 2020, 09:39:17 am »
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.

BrunoK

  • Sr. Member
  • ****
  • Posts: 262
  • Retired programmer
Re: Very serious flicker when StringGrids on PageControl
« Reply #12 on: June 01, 2020, 02:33:48 pm »
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)


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6608
  • Debugger - SynEdit - and more
    • wiki
Re: Very serious flicker when StringGrids on PageControl
« Reply #13 on: June 01, 2020, 03:06:27 pm »
Please put the patch on the bugtracker.

jamie

  • Hero Member
  • *****
  • Posts: 3524
Re: Very serious flicker when StringGrids on PageControl
« Reply #14 on: June 01, 2020, 03:38:55 pm »
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.
 :)
« Last Edit: June 01, 2020, 03:47:06 pm by jamie »
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018