ReDraw [Invalidate, Repaint, Update, Refresh] lazarus / 31-LCL ---------------------------------------------------------------------- RAW · 2018-03-11 18:27 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 · 2018-03-11 20:18 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 · 2018-03-11 20:42 @jamie: Thanks! QuoteRefresh 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. Interesting... never thought about doing something like that... ---------------------------------------------------------------------- Blaazen · 2018-03-11 21:40 @ 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 · 2018-03-11 23:49 QuoteYou 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 Thanks... good point.. haven't played around with these information delivered by LM_PAINT... ---------------------------------------------------------------------- taazz · 2018-03-12 02:31 Quote from: RAW on March 11, 2018, 07:27:28 pmRefresh:  calls Repaint  // not needed called by the end user to refresh the area of a control usually when there are property changes that do not refresh the control. Quote from: RAW on March 11, 2018, 07:27:28 pmRepaint:  If csOpaque Then direct redraw  Else calls Invalidate and Update As far as I remember from delphi repaint will handle all messages that have to do with painting invalidate, paint etc at the time it will be called. I used it to show progress updates on screen with out calling processmessages. Quote from: RAW on March 11, 2018, 07:27:28 pmInvalidate:  InvalidateRect  wich part is visible?  // can be used more than once, can reduce flicker The invalidated areas accumulate in the update region until the region is processed when the next WM_PAINT message occurs or until the region is validated by using the ValidateRect or ValidateRgn function. source https://msdn.microsoft.com/en- us/library/windows/desktop/dd145002(v=vs.85).aspx In short it does not matter how ofter you call invalidaterect it will accumulate the rect in to single region which will be passed to the next paint method. Used to speed things up. Quote from: RAW on March 11, 2018, 07:27:28 pmUpdate:  UpdateWindow  // no Invalidate, no waiting for WM_Paint, faster never used it my self. In short as a component writer I use invalidate/invalidaterect as an end user I use repaint. Now in lcl things are a bit out of spec for example repaint does not handle the paint messages at all as a result it does not update the screen at all. ---------------------------------------------------------------------- RAW · 2018-03-12 03:43 @taazz: Thanks for the info... I never really understood the differences and so normally I try all three to see if there are any differences. Normally I use Invalidate and in some cases Update to show a click effect with TImages or TLabels (looks nice and is very easy...). Right now I need some more advanced painting routines and I thought it's a good moment to dig a little bit more into this topic.