2
votes

Is there a simple and convenient way to tell when all the Components, Frames, and Child Controls on a TForm are fully painted? I'm basically looking for the equivalent of the onload() event found in web pages but in the context of Delphi forms. Preferably this technique would still work even if some form elements aren't currently visible and also it would fire again after a form resize occurred. I've got some form element "jiggling" going on as different form elements auto-adjust their size and I'd like to turn off repaints until it's all done to get a cleaner look.

2
You're asking the wrong question. Instead of asking about detecting the end of paint events, you should have just asked about how to position controls without flicker. Completely different question, especially when you consider controls that continuously update themselves, so they never finish painting. I suggest you edit your question so it asks what you really want to know.Rob Kennedy

2 Answers

0
votes

Delphi Controls have a BeginUpdate and EndUpdate procedure. Back when I did Delphi programming - it has been a while - we would want to load a grid that took a lot of data, we would call BeginUpdate before the load and then EndUpdate after load finished. This told the control to quit receiveing messages (ie. scrolling as new records loaded) and wait to update at one time - making everything "look" faster. You may be able to set controls to BeginUpdate mode until re-paint finish then EndUpdate to sync everything up.

0
votes

Take a look at DoubleBuffered property:

Determines whether the control’s image is rendered directly to the window or painted to an in-memory bitmap first. Delphi syntax: property DoubleBuffered: Boolean; Description When DoubleBuffered is false, the windowed control paints itself directly to the window. When DoubleBuffered is true, the windowed control paints itself to an in-memory bitmap that is then used to paint the window. Double buffering reduces the amount of flicker when the control repaints, but is more memory intensive. When a windowed control is a dock site and has an associated dock manager, it must be double-buffered. Note: Some controls, such as TRichEdit, can’t paint themselves into a bitmap. For such controls, DoubleBuffered must be set to false.