使区域无效的最佳方法 [英] Best way to invalidate an area

查看:141
本文介绍了使区域无效的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要同时使屏幕上的不同区域无效(发生在相同的功能中).

我可以为每个区域调用InvalidateRect(&rc):

I need to invalidate different areas on a screen at the same time (occurring in the same function).

I could invoke the InvalidateRect(&rc) for each area:

InvalidateRect(&rc);
InvalidateRect(&rc2);


或者我可以创建一个区域并将矩形添加到该区域,然后使用InvalidateRgn(&rgn);

我都做过,也不能说出任何区别.当我使用InvalidateRect()方法使每个调用的WM_PAINT矩形无效时,我并不确定.如果不是,我不确定通过使区域无效(由不同的矩形组成)而获得的好处.

任何想法或意见将不胜感激.


or I could create a region and add the rectangles to the region and then use InvalidateRgn(&rgn);

I''ve done both and can''t really tell any difference. I''m not convinced when I use the InvalidateRect() method to invalidate each rectangle that WM_PAINT is firing for each call. If it isn''t, I''m not sure of the advantage I''m receiving by invalidating a region (consisting of the disparate rectangles).

Any thoughts or opinions would be appreciated.

推荐答案

23_444写道:

我我不确信...每次调用都会触发WM_PAINT.

I''m not convinced ... that WM_PAINT is firing for each call.



没错,这些调用往往会被收集在一起,然后应用程序会获得一条WM_PAINT消息,以累积多个无效区域.至于这样做的好处,这完全取决于您的应用程序以及它随时试图显示的内容.看看 MSDN文档 [



You are correct, these calls tend to get collected together and then the app gets a single WM_PAINT message for an accumulation of more than one of the invalidated regions. As to the advantages of doing it this way, that depends entirely on your application and what it is trying to display at any time. Take a look at the MSDN documentation[^] for more information.


这篇关于使区域无效的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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