FMX: Control.Invalidate / Force repaint of a FMX control

    • Offizieller Beitrag

    It happens often that despite calling Invalidate the control is not painted.

    This is usually the case when the Invalidate routine is called in the context of user input.

    To solve the issue you need to set a flag in "Invalidate" and as soon as the application is idle call Invalidate.

    This code can be used to create a procedure which is called when the application is Idle:


    This is the message handler which is called when in the Idle cycle:

    Code
    procedure TCustomTool.IdleMessageHandler(const Sender: TObject; const Msg: System.Messaging.TMessage);
    begin
      if FNeedInvalidate then
      begin
        FNeedInvalidate := false;
        InvalidateRect(RectF(0,0,Width,Height));
      end;
    end;

    I hope this is helpful,

    Julian