RedrawWindow vs InvalidateRect

先看下MSDN上的解释

 

RedrawWindow:

 

This function updates the specified rectangle or region in the client area of a window.

 

 

InvalidateRect:

This function adds a rectangle to the specified window's update region. The update region represents the portion of the window's client area that must be redrawn.

 

RedrawWindow的作用是更新客户区的区域,可以是矩形或者非矩形.

 

InvalidateRect的作用是往窗口的需要重绘的区域中添加矩形.

 

揪出这两个函数来是因为有一个要显示类似即使速度的东西.用static实现,但是发现绘制会有重影.

调用InvalidateRect之后发现还是有时候会有重影.

 

也就是说InvalidateRect并不会立即更新.

 

 

The invalidated areas accumulate in the update region until the region is processed when the next WM_PAINT message occurs or until the region is validated by using the ValidateRect function.

The system sends a WM_PAINT message to a window whenever its update region is not empty and there are no other messages in the application queue for that window.

 

看看msdn上的解释.也就是说,当当前窗口没有其他消息的时候,而且当前需重绘区域不为空,才会发送WM_PAINT消息.

 

 而如果要实现即时的绘制.

RedrawWindow这个函数派上用场啦.

RedrawWindow 可以设置几种更新的方式,具体可以参考msdn.

 

 

也就是说微软提供了一个可以强制更新和非强制更新的手段让你来重绘.

 

补充:

另外补充一个绘制的api

UpdateWindow

 

看msdn 

This function updates the client area of the specified window by sending a WM_PAINT message to the window if the window's update region is not empty.

UpdateWindow sends a WM_PAINT message directly to the window procedure of the specified window, bypassing the application queue.

If the update region is empty, no message is sent.

 

这个函数只负责重绘.但是不会发送WM_ERASEBKGND消息.所有这是跟RedrawWindow的区别 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值