When to use TPanel FullRepaint?
Asked Answered
S

2

6

I noticed that the resize flicker gets much better when I set TPanel.FullRepaint to False. Since the property exists and is True by default, there must be some reason for that.

How to decide whether it should be set or not?

The help just states:

FullRepaint controls how the panel responds when it is resized. When FullRepaint is true, the entire panel, including the beveled border repaints when the size changes. When FullRepaint is false, only the area inside the beveled border repaints.

http://docwiki.embarcadero.com/Libraries/XE3/en/Vcl.ExtCtrls.TPanel.FullRepaint

That text says what it does, but not why ...

Sentience answered 10/2, 2013 at 0:54 Comment(1)
Deal with resize flicker like this: #8059245Poplar
D
4

The effect of a missing Fullrepaint can be shown and you will have to decide if you need it or not.

  1. Place a panel on a form, set anchors to all directions
  2. Set PaintCaption to false or use a empty caption
  3. Place another panel on the form, so that if you are resizing the form, parts of the first panel will be covered by the second panel.

Run the program and size the form, somtimes the borders of the first panel will not be refreshed.
This happens because in WMWindowPosChanged in case of (FullRepaint or (ShowCaption and (Caption <> ''))) a invalidate will be called, otherwise only InvalidateRect(Handle, Rect, True) of a rects only containing the right and/or bottom border are invalidated. (thanks to Sertac Akyuz for correction)

As you mentioned avoiding invalidate reduces flicker and in many cases the need for a full invalidate is not given, so the user can decide on his own how to proceed.

Panels as the rarely will be used, upper without Fullrepaint

Deflate answered 10/2, 2013 at 7:21 Comment(4)
"...otherwise only InvalidateRect(Handle, Rect, True) of a rect excluding the borders." This is incorrect and your explanation does not match with the code. On the contrary, when FullRepaint is false (and there's no caption) only a rect containing the right and/or bottom border is invalidated - not a rect excluding the borders.Treasure
So FullRepaint := True is only needed when the panel is overlapped by some other control?Wickiup
any resizing can cause artefacts try : begin Panel1.Width := Random(200) end;Deflate
@Jens - It would seem FullRepaint is needed when the panel has any bevel/border and the panel's size is not fixed. I find this rather strange, the panel has to invalidate itself just to paint its border/bevel correctly. This looks like a workaround for some defect elsewhere.Treasure
A
0

In previous versions of Windows (not sure up to which version, exactly) FullRepaint was required to prevent graphical artefacting on panel borders when a form was resized. To the best of my knowledge, this hasn't been an issue since at least Windows XP.

Annul answered 10/2, 2013 at 0:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.