简体   繁体   English

刷新、更新和重绘有什么区别?

[英]What's the difference between Refresh, Update and Repaint?

I don't know which of those three methods suits me most.我不知道这三种方法中哪一种最适合我。 They all work for me.他们都为我工作。 Does anyone know the difference between Refresh, Update and Repaint?有谁知道刷新、更新和重绘之间的区别?

According to the online documentation:根据在线文档:

Refresh - Repaints the control on the screen. 刷新- 在屏幕上重新绘制控件。

Call Refresh method to repaint the control immediately.调用 Refresh 方法立即重新绘制控件。 Refresh calls the Repaint method. Refresh 调用 Repaint 方法。 Use the Refresh and Repaint methods interchangeably.交替使用 Refresh 和 Repaint 方法。

Repaint - Forces the control to repaint its image on the screen. 重画-强制重绘屏幕上其图像的控制。

Call Repaint to force the control to repaint its image immediately.调用 Repaint 强制控件立即重新绘制其图像。 If the ControlStyle property includes csOpaque, the control paints itself directly.如果 ControlStyle 属性包含 csOpaque,则控件会直接绘制自身。 Otherwise, the Repaint method calls the Invalidate method and then the Update method so that any visible portions of controls beneath the control will be repainted as well.否则,Repaint 方法调用 Invalidate 方法,然后调用 Update 方法,以便控件下方的控件的任何可见部分也将被重新绘制。

Update - Processes any pending paint messages immediately. 更新- 立即处理任何挂起的绘制消息。

Call Update to force the control to be repainted before any more, possibly time-consuming, processing takes place.调用 Update 以强制重新绘制控件,然后再进行可能耗时的处理。 Use Update to provide immediate feedback to the user that cannot wait for the Windows paint message to arrive.使用更新向无法等待 Windows 绘制消息到达的用户提供即时反馈。

Update does not invalidate the control, but simply forces a repaint of any regions that have already been invalidated.更新不会使控件失效,而只是强制重新绘制已经失效的任何区域。 Call Repaint instead to invalidate the control as well.调用 Repaint 也可以使控件无效。

Your question is already answered, but if you need good performance and less flicker you should call Invalidate instead.您的问题已得到解答,但如果您需要良好的性能和更少的闪烁,则应改为调用 Invalidate。 It allows Windows to optimize the painting process.它允许 Windows 优化绘画过程。

Invalidate - Completely repaint control. 无效- 完全重绘控件。

Use Invalidate when the entire control needs to be repainted.当需要重新绘制整个控件时使用 Invalidate。 When more than one region within the control needs repainting, Invalidate will cause the entire window to be repainted in a single pass, avoiding flicker caused by redundant repaints.当控件内有多个区域需要重绘时,Invalidate 会导致整个窗口一次重绘,避免重复重绘造成的闪烁。 There is no performance penalty for calling Invalidate multiple times before the control is actually repainted.在实际重绘控件之前多次调用 Invalidate 没有性能损失。

Per an older (CBuilder 6) VCL reference:根据较旧的(CBuilder 6)VCL 参考:

Invalidate "Invalidate informs a control that its entire surface needs to be repainted. Calling Invalidate can prevent flicker caused by a series of partial repaints. There is no performance penalty for calling Invalidate multiple times before the control is actually repainted". Invalidate “Invalidate 通知控件它的整个表面需要重绘。调用 Invalidate 可以防止由一系列部分重绘引起的闪烁。在控件实际重绘之前多次调用 Invalidate 不会造成性能损失”。

The actual repaint does not occur until the control is updated.在控件更新之前不会发生实际的重绘。 To force an immediate repaint, call Repaint instead.要强制立即重绘,请改为调用 Repaint。

Repaint "TWinControl::Repaint calls the Invalidate method and then the Update method to repaint the control" (slight paraphrase).重绘“TWinControl ::重绘调用Invalidate方法,然后更新的方法来重绘控制”(意译轻微)。

(Sadly, the older reference is better and more complete than the newer reference I have (CBuilder 2007). (遗憾的是,较旧的参考资料比我拥有的较新的参考资料(CBuilder 2007)更好、更完整。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM