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 ...

Jens Mühlenhoff
  • 14,565
  • 6
  • 56
  • 113
  • 2
    Deal with resize flicker like this: http://stackoverflow.com/questions/8058745/tlabel-and-tgroupbox-captions-flicker-on-resize – David Heffernan Feb 10 '13 at 09:06

2 Answers2

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

bummi
  • 27,123
  • 14
  • 62
  • 101
  • 2
    *"...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. – Sertac Akyuz Feb 10 '13 at 10:37
  • 1
    So `FullRepaint := True` is only needed when the panel is overlapped by some other control? – Jens Mühlenhoff Feb 10 '13 at 11:46
  • any resizing can cause artefacts try : begin Panel1.Width := Random(200) end; – bummi Feb 10 '13 at 12:06
  • @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. – Sertac Akyuz Feb 10 '13 at 12:55
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.

LaKraven
  • 5,804
  • 2
  • 23
  • 49