Forum > LCL

ReDraw [Invalidate, Repaint, Update, Refresh]

(1/2) > >>

RAW:
Refresh:
 calls Repaint  // not needed

Repaint:
 If csOpaque Then direct redraw
 Else calls Invalidate and Update

Invalidate:
 InvalidateRect
 wich part is visible?  // can be used more than once, can reduce flicker

Update:
 UpdateWindow  // no Invalidate, no waiting for WM_Paint, faster


Has anybody seen some really good examples to really explain this ???
When do I use what?

Normally -> Invalidate
Fast       -> Update

????

jamie:
Refresh is there so you can override it to have your control do other unique updates and then
call the inherited, which in this case is calling repaint.
 
 This makes is easier to make changes to the surface settings or maybe setup a region before repaint.

 " Invalidate" basically will call send a Paint message to the control after other messages in the que have
been processed, it also invalidates the whole control and forces a complete update.
 
 I believe windows will purge any pending invalidate after this gets processed so this means you don't
get repeating painting and there should be no regions set.

As for "Update" what it suppose to do is basically force a WM_PAINT to the control directly if there
was a invalidate done but still sitting in the buffer, this is suppose to check for that check and force
the repaint and then remove the pending invalidate.

 That I can't tell you how well that is supported.

 I wanted to add the UPDATE will also process all the other waiting messages and process any regions
waiting.

 Where as, Repaint just simple does the whole control.

RAW:
@jamie: Thanks!


--- Quote ---Refresh is there so you can override it to have your control do other unique updates and then
call the inherited, which in this case is calling repaint.
This makes is easier to make changes to the surface settings or maybe setup a region before repaint.

--- End quote ---
Interesting... never thought about doing something like that...

Blaazen:
@ Invalidate:
 InvalidateRect
 wich part is visible?

When you call Invalidate or InvalidateRect, Paint method will follow. Even more, Paint may be called by widgetset of some reason. It may happen that you call InvalidateRect, then other Invalidate or requirement to repaint is called, and Paint of the full area will come (i.e. repaint of the single rectangle specified in InvalidateRect never happen).

You can get the actual area to be repainted easily. Each method Paint is preceded by WMPaint message method. Its parameter Message: TLMPaint contains coordinates:
Message.PaintStruct^.rcPaint.Left
Message.PaintStruct^.rcPaint.Top
Message.PaintStruct^.rcPaint.Right
Message.PaintStruct^.rcPaint.Bottom

RAW:

--- Quote ---You can get the actual area to be repainted easily. Each method Paint is preceded by WMPaint message method. Its parameter Message: TLMPaint contains coordinates:
Message.PaintStruct^.rcPaint.Left
Message.PaintStruct^.rcPaint.Top
Message.PaintStruct^.rcPaint.Right
Message.PaintStruct^.rcPaint.Bottom

--- End quote ---
Thanks... good point.. haven't played around with these information delivered by LM_PAINT...

Navigation

[0] Message Index

[#] Next page

Go to full version