TTabSheet Flickers

Hi everybody.

I have a form with a TPageControl that contains a TTabSheet with a TImage and a Timer that refreshes the TImage every 300 ms, and thats making the TImage flickers.  When I'm not using the TPageControl, placing the Image directly on the form the flicker did not happen. Does anybody knows how to stop the flicker inside the TTabSheet?

I've set the DoubleBuffered property from TForm, TPageControl and TTabSheet to true and nothing change.

Thanks ...
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Why refresh the image? Does it change every 300ms? If not, why not check whether it has changed and only update it on screen only if it has changed?

Alternatively try a TPaintBox and StretchDraw your image onto that when required.

Geoff M.
MauricioMaiaAuthor Commented:
Yeah, the image changes every 300ms.
I'm refreshing the image that comes from a capture board. And I use the canvas from TImage to select areas from the image (using canvas.rectangle and drawfocusrect), that will be used as reference to a motion detector.
So does it flicker every 300ms or more frequently?

Geoff M.
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

If the problem only occurs when all the stuff is in a TPage Control, then perhaps it comes from the TPageControl redrawing itself of from the handling of the "Hey, everybody, redraw now" messages between the TPageControl and its children.

Have you tried a using a TTabControl rather than a TPageControl? It's a bit more of work because you have to control when each component goes invisible or visible with your own code, but if you do it carefully you might get a better performance that will do the trick.

Hope it helps:

MauricioMaiaAuthor Commented:

Geoff M., the flicker did not occurs every 300ms. It didn't have a constant frequency but occurs more frequently when the mouse pointer is  above the TImage.

Jack - With the TTabControl I get less flicker but It still have much enough to disturb the user interface.


Then try this:

On an empty form put the image. Then put the TTabControl beside it. Now drag the image and place it over the TabControl. Now it is OVER the TTabControl. Not IN it.
It should be as good as putting it directly on the form (in fact it IS putting it right on the form).
(Be carefull, if you destroy the TabControl, the image won't get destroyed).

By way of example, here you have a form (with "View as Text") with a Button1 IN the TabControl and Button2 OVER it:

object Form1: TForm1
  Left = 192
  Top = 107
  Width = 696
  Height = 480
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object TabControl1: TTabControl
    Left = 200
    Top = 56
    Width = 289
    Height = 193
    TabOrder = 0
    Tabs.Strings = (
    TabIndex = 0
    object Button1: TButton
      Left = 104
      Top = 88
      Width = 75
      Height = 25
      Caption = 'Button1'
      TabOrder = 0
  object Button2: TButton
    Left = 304
    Top = 184
    Width = 75
    Height = 25
    Caption = 'Button2'
    TabOrder = 1

It's an extremely dirty solution. In fact it's not a solution, it's just a work around, so if any other experts have more sugestions, my advise is to keep listening. But this might do the trick.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MauricioMaiaAuthor Commented:
I will split points between JackNaif and gmayo (His suggestion to use TPaintBot did work). Both found alternative ways to solve the problem. Thanks everybody for the help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.