Firemonkey - visual component update

We have been working with Firemonkey since version 1 and still find it difficult to update the components that are currently visible on the screen. There are many “ways” to request a redraw in Firemonkey, perhaps too many:

  • Applying a style (ApplyStyle event) - mainly when it becomes visible on the screen
  • Request ".repaint" - some components have this
  • ".Realign" request - sometimes works, current versions of FMX seem to drop / hide it
  • Request ".invalidate" - some components, mainly forms, have this
  • Request ".invalidateRect" - most components have this
  • Calling the ApplyStyle event manually - operation and design are not guaranteed - incorrect ...

Given the lack of documentation for the platform, is there a “well-defined” way to change the look (internal style values) when a component is already displayed? That is, a listboxItem that is already present and displayed on the screen, a TGrid cell, etc. Your thoughts will be appreciated ...

+4
source share
1 answer

I don’t think there is one unified “right way” for updating visual components in Firemonkey.

However, as a recommendation from personal experience, I would take the .repaint route - this method is at the TControl level, and therefore it precedes primitives and stylish controls (which usually consist of primitives) and therefore applies to all visual controls. It also does not require parameters, so this is a good comprehensive solution.

I noticed that Firemonkey always had a problem correctly redrawing the controls themselves. Often I stay with the “shadow” of the previous visual control / primitive and have to call .repaint manually to update it. This has noticeably worsened with FM2 and FM3 (presumably due to optimizations for mobile platforms), and therefore does the .repaint , especially if effects like TGlow and moving or rotating controls / primitives have become standard practice for me.

+2
source

Source: https://habr.com/ru/post/1495467/


All Articles