刷新、更新和重画之间有什么区别?

发布于 2024-08-01 12:40:38 字数 56 浏览 5 评论 0原文

我不知道这三种方法中哪一种最适合我。 他们都为我工作。 有谁知道刷新、更新和重画之间的区别吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

故人如初 2024-08-08 12:40:38

根据在线文档:

刷新 - 重新绘制屏幕上的控件。

调用Refresh方法重新绘制
立即控制。 刷新调用
重涂法。 使用刷新和
重绘方法可以互换。

重新绘制 - 强制控件重新绘制它在屏幕上的图像。

调用 Repaint 来强制控件
立即重新绘制其图像。 如果
ControlStyle 属性包括
csOpaque,控件自行绘制
直接地。 否则,重画
方法调用 Invalidate 方法并且
然后更新方法,以便任何
下面的控件的可见部分
控件也将被重新绘制。

更新 - 处理任何待处理的绘制消息立即地。

调用 Update 来强制控制
可能之前重新粉刷过
耗时,处理需要
地方。 使用更新提供即时
反馈给迫不及待的用户
将 Windows 绘制消息发送至
到达。

更新不会使
控制,但只是强制重新绘制
任何已经存在的地区
无效。 调用 Repaint 来代替
控制也无效。

According to the online documentation:

Refresh - Repaints the control on the screen.

Call Refresh method to repaint the
control immediately. Refresh calls the
Repaint method. Use the Refresh and
Repaint methods interchangeably.

Repaint - Forces the control to repaint its image on the screen.

Call Repaint to force the control to
repaint its image immediately. If the
ControlStyle property includes
csOpaque, the control paints itself
directly. 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.

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. Use Update to provide immediate
feedback to the user that cannot wait
for the Windows paint message to
arrive.

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.

淡淡的优雅 2024-08-08 12:40:38

根据较旧的 (CBuilder 6) VCL 参考:

Invalidate “Invalidate 通知控件需要重新绘制其整个表面。调用 Invalidate 可以防止由一系列部分重新绘制引起的闪烁。不会有性能损失在控件实际重新绘制之前多次调用 Invalidate”。

在更新控件之前,不会发生实际的重绘。 要强制立即重新绘制,请改为调用 Repaint。

Repaint “TWinControl::Repaint 调用 Invalidate 方法,然后调用 Update 方法来重新绘制控件”(轻微释义)。

(遗憾的是,旧的参考文献比我拥有的新参考文献(CBuilder 2007)更好、更完整。

Per an older (CBuilder 6) VCL reference:

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".

The actual repaint does not occur until the control is updated. To force an immediate repaint, call Repaint instead.

Repaint "TWinControl::Repaint calls the Invalidate method and then the Update method to repaint the control" (slight paraphrase).

(Sadly, the older reference is better and more complete than the newer reference I have (CBuilder 2007).

辞取 2024-08-08 12:40:38

您的问题已经得到解答,但如果您需要良好的性能和更少的闪烁,您应该调用 Invalidate。 它允许 Windows 优化绘画过程。

无效 - 完全重绘控件。

当整个控件使用Invalidate
需要重新粉刷。 当超过
控制需求范围内的一个区域
重画,Invalidate会导致
整个窗户要重新粉刷
单次通过,避免造成闪烁
通过多余的重画。 没有
调用的性能损失
之前多次失效
控件实际上被重新绘制。

Your question is already answered, but if you need good performance and less flicker you should call Invalidate instead. It allows Windows to optimize the painting process.

Invalidate - Completely repaint control.

Use Invalidate when the entire control
needs to be repainted. 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. There is no
performance penalty for calling
Invalidate multiple times before the
control is actually repainted.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文