invalidate方法如何处理多个请求? [英] How does the invalidate method deal with multiple requests?

查看:111
本文介绍了invalidate方法如何处理多个请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是这个论坛的新手,我必须说我觉得文章很有趣.

无论如何,我希望获得一些帮助来理解用来使表单上的区域无效的invalidate方法如何处理多个请求.我有一个应用程序,该应用程序具有我开发的多个UI类,这些类将在需要指定区域时失效.我创建了一个渲染引擎,因为某些UI相互堆叠,但是问题在于,在接收到OnPaint之前,将从多个UI调用无效对象,从而每次更改区域并导致更新问题. (为了节省详细信息,我对此进行了一些简化,但这是实际发生的事情.)

我的关键问题是,使区域无效的方法是否排队,而OnPaint响应是否与无效区域的顺序有关?即就无效/OnPaint行为而言的FIFO.

任何帮助将不胜感激.

谢谢

Andy

解决方案

每次调用Invalidate()都会将该区域添加到需要重新粉刷的总区域中.然后,在调用repaint方法时,它将接收该总区域的详细信息.看看 MSDN描述 [ 解决方案

Each call to Invalidate() adds the region to the total area that needs repainting. Then when the repaint method is called it will receive details of that total region. Take a look at the MSDN description[^] for more details.


As Richard said, multiple Invalidate() calls accumulate their invalid regions. However, the documentation does not specify whether it uses the optimal way to accumulate. I recall an old experiment where two non-overlapping rectangles got accumulated to their rectangular hull. As the exact behavior is undocumented, the behavior may change over time, and all you can trust is a sufficient region will be repainted eventually.

:)


这篇关于invalidate方法如何处理多个请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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