InvalidateRect和RedrawWindow之间的差异 [英] Difference between InvalidateRect and RedrawWindow

查看:212
本文介绍了InvalidateRect和RedrawWindow之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想重新绘制一个窗口时,是否有任何首选函数调用InvalidateRect和RedrawWindow?

When I want to redraw a window, is there any preferred function to call between InvalidateRect and RedrawWindow?

例如,这两个调用是否相等:是HWND)

RedrawWindow(win,NULL,NULL,RDW_INVALIDATE);

InvalidateRect(win,NULL,NULL);

For instance, are these two calls equal: (win would be a HWND)
RedrawWindow(win, NULL, NULL, RDW_INVALIDATE);
InvalidateRect(win, NULL, NULL);

主要问题:我应该何时使用其中一个?在背景中有没有什么不同? (不同的WM_messages /焦点/顺序/优先级..)

The main question(s): When should I use one or the other? Are there any differences that happen in the background? (different WM_messages / focus / order / priorities..)

我想重新绘制窗口的原因是因为我发送一个新的图像,显示,表示窗口的内容不再有效。

The reason that I want to redraw the window is because I send a new image to it that I want it to display, meaning the content of the window is no longer valid.

推荐答案

InvalidateRect 不立即重新绘制窗口。它只是调度窗口的特定矩形区域的未来重绘。使用 InvalidateRect ,您可以安排任意多个区域,使它们在某些内部缓冲区中累积。对于所有累积的预定区域的实际重绘将在稍后,当窗口没有别的东西时进行。 (当然,如果在发出 InvalidateRect 调用时窗口处于空闲状态,重新绘制将立即执行)。

InvalidateRect does not immediately redraw the window. It simply "schedules" a future redraw for a specific rectangular area of the window. Using InvalidateRect you may schedule as many areas as you want, making them accumulate in some internal buffer. The actual redrawing for all accumulated scheduled areas will take place later, when the window has nothing else to do. (Of course, if the window is idle at the moment when you issue the InvalidateRect call, the redrawing will take place immediately).

您还可以通过调用 UpdateWindow 强制立即重新绘制当前累积的所有无效区域。但是,如果你不快,明确调用 UpdateWindow 是没有必要的,因为一旦窗口空闲,它将自动对所有当前无效的区域执行重绘。

You can also force an immediate redraw for all currently accumulated invalidated areas by calling UpdateWindow. But, again, if you are not in a hurry, explicitly calling UpdateWindow is not necessary, since once the window is idle it will perform a redraw for all currently invalidated areas automatically.

另一方面,RedrawWindow 是一个具有更广泛和灵活的功能集的功能。它可以用于执行无效调度(即,同样的事情 InvalidateRect ),或者它可以用于强制执行立即重新绘制指定区域,而不进行任何调度 。在后一种情况下,调用 RedrawWindow 实际上等效于调用 InvalidateRect ,然后立即调用 UpdateWindow

RedrawWindow, on the other hand, is a function with a much wider and flexible set of capabilities. It can be used to perform invalidation scheduling (i.e. the same thing InvalidateRect does) or it can be used to forcefully perform immediate redrawing of the specified area, without doing any "scheduling". In the latter case calling RedrawWindow is virtually equivalent to calling InvalidateRect and then immediately calling UpdateWindow.

这篇关于InvalidateRect和RedrawWindow之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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