What's the difference in the Refresh, Update, Repaint, Invalidate, and Application.ProcessMessages methods?

11

What's the difference between the methods:

  • Refresh , from TControl;
  • Update , from TControl;
  • Repaint , also from Control; e,
  • Invalidate , also from TControl;
  • In addition to the Application.ProcessMessages ?
  • asked by anonymous 20.10.2014 / 01:38

    1 answer

    13

    Invalidate

    The Invalidate method 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-wishes the component immediately, as long as it has already been invalidated, without waiting for the processing of the re-draw messages by Windows. Generates processor time consumption because you will stop all activities from the main application thread to redraw.
    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 the component to re-draw immediately. If the ControlStyle property includes csOpaque , the component will be redrawn, otherwise the Invalidate method will be executed and soon the Update

    Refresh

    According to the documentation, the Refresh executes the Repaint , and therefore exactly do the table thing, both of which are interchangeable, that is, either use one or the other

    Application.ProcessMessages

    Force the application to process Windows messages.

    When the application is performing a high-cost operation, or looping, the thread gets busy performing that operation and does not process any Windows messages to the application, such as a click on a component , keystroke or in this case update the graphic components of the application.

    If you call the Invalidate method and soon after Application.ProcessMessages , windows will handle the Invalidate message and arrange the re-drawing of the window or component together with all other messages.

        
    20.10.2014 / 13:23