Firemonkey-更新视觉组件 [英] Firemonkey - updating visual components

查看:108
本文介绍了Firemonkey-更新视觉组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们从版本1开始使用Firemonkey,但仍然难以更新屏幕上当前可见的组件。在Firemonkey中有很多请求重绘的方法,也许太多:

We are working with Firemonkey since version 1, and still find difficulties updating components that are currently visible on the screen. There are many 'ways' to request a repaint in Firemonkey, perhaps too many:


  • 应用样式(ApplyStyle事件)-主要是在应用样式时变得在屏幕上可见

  • 请求 .repaint-一些组件具有此功能

  • 请求 .repaint-有时有效,当前版本的FMX似乎删除/隐藏它

  • 请求 .invalidate-一些组件(主要是表单)具有此

  • 请求 .invalidateRect-大多数组件具有这

  • 手动调用ApplyStyle事件-不保证能正常工作,并且在设计方面是不正确的...

  • Applying a style (ApplyStyle event) - mostly when it becomes visible on screen
  • Requesting ".repaint" - some components have this
  • Requesting ".realign" - sometime works, current versions of FMX seem to drop / hide it
  • Requesting ".invalidate" - some components, mostly forms, have this
  • Requesting ".invalidateRect" - most components have this
  • Calling the ApplyStyle event manually - not guaranteed to work and design-wise is incorrect...

鉴于缺少该平台的文档,当已经显示组件时,是否存在一种定义明确的方法来更改视觉外观(样式的内部值)?即一个已经存在并在屏幕上可见的listboxItem,一个TGrid单元格等等。感谢您的想法...

Given the lacking documentation for the platform, is there a "well defined" way to change the visual appearance (internal values of a style) when a component is already displayed? I.e. a listboxItem that is already present and visible on screen, a TGrid cell, and so on. Would appreciate your thoughts...

推荐答案

我不认为有一种统一的正确方法可以刷新

I don't think there's a single unified 'correct way' to refresh the visual of components in Firemonkey.

但是,根据个人经验的建议,我会选择 .repaint 路线-此方法位于 TControl 级别,因此它在基元和样式控件(通常由基元组成)之前,因此适用于所有可视控件。它也不需要参数,因此它是一个很好的全方位解决方案。

However, as a recommendation from personal experience, I'd take the .repaint route - this method is at the TControl level, and so it precedes primitives and styled controls (which are generally made up of primitives) and so applies to all visual controls. It also doesn't require parameters, so it's a good all-round solution.

我注意到Firemonkey一直存在一个问题,即如何正确地重新绘制自己的控件。通常,我会留下控件/基元以前的视觉效果的阴影,必须手动调用 .repaint 进行更新。在FM2和FM3上,情况变得更糟(大概是由于针对移动平台进行了优化),因此手动进行 .repaint 尤其是在诸如 TGlow 和移动或旋转控件/基元有关,这已成为我的标准做法。

I have noted that Firemonkey has always had an issue correctly repainting controls of it's own accord. Often I'm left with a 'shadow' of the previous visual of a control/primitive, and must call .repaint manually to update it. This got noticeably worse with FM2 and FM3 (presumably due to optimizations made for mobile platforms), and so doing a manual .repaint -- especially where effects such as TGlow and moving or rotating controls/primitives are concerned, has become a standard practice for me.

这篇关于Firemonkey-更新视觉组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆