本文介绍了WinAPI双缓冲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认的winAPI应用程序没有双缓冲。相反,它做一个非常非常好的工作,确保只有需要绘制的东西被绘制,并给它一个无缝的外观。但是,当调整窗口大小时,整个事件需要重绘,这会导致控件之间,选项卡上的背景,以及有时候选项卡的白色闪烁。

A default winAPI application does not have double-buffering. Instead, it does a very, very good job of ensuring that only what needs to be drawn is drawn, and that gives it a seamless appearance. However, when you resize the window, the entire thing needs to be redrawn, and this causes flickering between the controls, the background on the tab, and sometimes the white of the tab.

所以我的问题是,在我的应用程序中支持双缓存的最简单的方法是什么?

So my question is, what is the easiest way to support double buffering in my application?

推荐答案

你可以做一个非常直接的在位替换在您现有的代码。

You can do a pretty straight-forward in-place replacement in your existing code. Instead of using a device context that renders into the window, use one that renders into the bitmap, and only use the original DC to blit the bitmap back.

请务必使用一个可以转换为位图格式的设备上下文,而不使用渲染到窗口中的设备上下文。保持位图周围 - 不要在每次绘制调用中创建它。您只需要在调整窗口大小时重新创建它。

Be sure to keep the bitmap around - don't create it in every paint call. You just need to recreate it when the window is resized.

这篇关于WinAPI双缓冲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 12:00