在这种情况下如何使用双缓冲区?

发布于 2024-08-06 12:14:48 字数 489 浏览 3 评论 0原文

假设我有三个控件A、B、C。它们都是继承自CDialog, A是一个主对话框,A包含B,B包含C。 每次我用鼠标拖动C时,B和C都会一起移动。

这是一张图片:http://img507.imageshack.us/img507/7039/31709956 .jpg

我们知道这会导致 B 和 C 重绘自己。并且可能会引起闪烁。

我的问题是是否有一种方法可以双缓冲这两个对话框 B 和 C?

我知道在 XP 和 Vista 中,有一个属性 WS_EX_COMPOSITED 会有所帮助,但我不想使用它。

有人可能建议我使用 memDC,但我的问题是如何将 B 的 ondraw 和 C 的 ondraw 函数中的操作合并到缓冲区中?

希望有人知道我说的话。

提前致谢!

Let's say i have three control A, B, C. They are all inherited from CDialog,
A is a main dialog , A contains B, and B contains C.
and each time i use mouse mouse drag C, B and C will move together.

This is a image:http://img507.imageshack.us/img507/7039/31709956.jpg

We know this will cause B and C to redraw themselves. and it might cause flicker.

And my question is whether not there is a method to double buffer these two dialogs B and C?

I know that in XP and vista, there is a attribute WS_EX_COMPOSITED that will help, but i don't want to use this.

someone might suggest me to use memDC, but my problem is how can i merge the actions in B's ondraw and C's ondraw function into a buffer ?

Hope someone know what i said.

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

孤寂小茶 2024-08-13 12:14:48

对闪烁有很大帮助的是重载erasebackground方法。此方法用纯色填充整个背景。油漆会将所有物品涂在上面。通过删除擦除背景,油漆将只绘制已经存在的东西,从而消除闪烁。

what helpes flickering a lot is to overload the erasebackground method. This method fills the entire background with a solid color. The paint than paints all items on it. By removing the erasebackground, the paint will just paint over stuff which is already there, thus removing flickering.

南风起 2024-08-13 12:14:48

CS_PARENTDC 会有所帮助。

CS_PARENTDC will help.

躲猫猫 2024-08-13 12:14:48

我自己从来没有搞乱过双缓冲 Windows 的绘图调用,但我曾经在 Microsoft 论坛上遇到过关于它的讨论:http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/789a4116-d3b2- 488e-801a-3f7bc1e4d33a/ 也许这对您有帮助。

I've never messed with double-buffering Windows' drawing calls myself, but I once came across a discussion about it on a Microsoft forum: http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/789a4116-d3b2-488e-801a-3f7bc1e4d33a/ Perhaps that might be helpful to you.

源来凯始玺欢你 2024-08-13 12:14:48

假设 B 和 C 是 A 的子级(对话框的常见情况),A 应该设置 WS_CLIPCHILDREN 样式。如果 B 和 C 是 A 的同级,则设置 A 的 WS_CLIPSIBLINGS 位。

Assuming B and C are children of A (the usual case for dialogs), A should have the WS_CLIPCHILDREN style set. If B and C are siblings of A instead, set A's WS_CLIPSIBLINGS bit.

久随 2024-08-13 12:14:48

主对话框 A 取一个 MemDC,B 和 B 取组合 MemDC。 C.
现在,当你拖动 C 时,你应该根据当前位置组合这 2 个 MemDC
通过使用 BitBlt 函数,最后您必须在对话框的实际 DC 上执行组合 memDC 的 bitblt。

除此之外,您还必须重写 onerasebackground 方法,这样就不会出现闪烁。

Take one MemDC for main dialog A and Combined MemDC for B & C.
Now when u drag C , you are supposed to combined these 2 MemDC depending on current position
by using BitBlt function and then finally you have to do bitblt of combined memDC on actual DC of the dialog.

Along with this you have to override onerasebackground method , so flicker wont be there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文