What’s the difference in Refresh, Update, Repaint, Invalidate and Application.Processmessages methods?

Asked

Viewed 4,766 times

11

1 answer

14


Invalidate

The method Invalidate only marks the component to be painted the next time the interface is updated. It does not re-draw the component at the time it was called.

Update

Method that re-scores the component immediately, since it has already been invalidated, without waiting for the processing of re-drawing messages by Windows. Generates processor time consumption as you will stop all activities of the application’s main thread to redesign.
This means that if you have changed something that implies a visual change, and the component has not been Invalidated, after the update the change may not be processed.

Repaint

repaint forces component to re-draw immediately. If property ControlStyle include csOpaque, component will redesign, otherwise the method will be executed Invalidate and then the method Update

Refresh

According to the documentation the Refresh executes the Repaint, and therefore do exactly the table thing, so much so that it is still stated that they are interchangeable, that is, either use one or the other

Application.Processmessages

Forces the application to process Windows messages.

When the application is performing a high-cost processing operation, or looping, the thread is busy performing that operation and does not process any Windows message to the application, such as a click on a component, the pressing of a key or in this case the updating of the graphical components of the application.

Be call the method Invalidate and right after Application.ProcessMessages, windows will handle the Invalidate message and provide the re-design of the window or component along with all other messages.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.