刷新、更新和重画之间有什么区别?
我不知道这三种方法中哪一种最适合我。 他们都为我工作。 有谁知道刷新、更新和重画之间的区别吗?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据在线文档:
刷新 - 重新绘制屏幕上的控件。
重新绘制 - 强制控件重新绘制它在屏幕上的图像。
更新 - 处理任何待处理的绘制消息立即地。
According to the online documentation:
Refresh - Repaints the control on the screen.
Repaint - Forces the control to repaint its image on the screen.
Update - Processes any pending paint messages immediately.
根据较旧的 (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).
您的问题已经得到解答,但如果您需要良好的性能和更少的闪烁,您应该调用 Invalidate。 它允许 Windows 优化绘画过程。
无效 - 完全重绘控件。
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.