MFC:如何避免在子控件更新中闪烁? [英] MFC: How to avoid flickering in child-control updates?

查看:99
本文介绍了MFC:如何避免在子控件更新中闪烁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了好几天,得到的答案都是相同的,但不是我想要的(稍后将描述我不想要的内容).

I'm been googling for days, and all I'm getting are the same answers, but is not what I want (I will describe what I do not want later).

我想要的是:

  • 说我有一个带有一些CStatic子控件的父对话框.
  • 父对话框在焦点对准时使用黑色作为背景,在焦点不对准时使用灰色.
  • 子级静态控件仅显示文本,但是其背景需要遵循父级的背景颜色

问题:

  • 我可以使子控件始终跟踪父级的颜色,但是更新颜色的过程很慢,并且会导致闪烁.
  • 使对话框成为焦点时,可以看到对话框的颜色从灰色更改为黑色,然后每个文本控件也从灰色更改为黑色.
  • 速度很慢,因为它在嵌入式设备上.

双缓冲将不起作用,因为父级和子级都有自己的绘制例程,因此我认为不可能共享相同的缓冲区.我读过WS_EX_COMPOSITE或某些适用于Vista的东西,但我使用的是较低端的操作系统.

Double buffering would not work because the parent and child has it's own paint routine, so I think it is impossible to share the same buffer. I've read that WS_EX_COMPOSITE or something works for Vista, but I am on a lower end OS.

我不需要的:

  • 我已经了解了如何覆盖背景擦除例程(这就是为什么我已经可以更新控件的原因了)
  • 我知道一般如何使用CMemDC,但如上所述,它不适用于我的情况.

有什么主意吗?我敢肯定处理速度会发挥作用,但我坚信这只是一种技术或设置,我没有正确地做到这一点.我记得我的第一台PC是133MHz,但是当他们的父母失去焦点时,我不记得Windows 95一次一个地更新控件了-它们几乎立即更新.那时我什至没有好的视频卡.

Any ideas, guys? I'm sure processing speed plays a part, but I strongly believe it is just a technique or setting that I am not doing it right. I remember my first PC being a 133MHz, but I don't recall Windows 95 updating controls on-by-one when their parent loses focus -- they update almost instantly. And I don't even have a good video card back then.

请帮助.

添加项: -我尝试使控件的BkMode变为TRANSPARENT,甚至使用NULL_BRUSH.所有这些连同ON_WM_CTLCOLOR.我得到的只是一个带有孔的对话框,而在这些孔中是控制文本.换句话说,没有绘制控件的背景,而是绘制对话框(如NULL_BRUSH所期望的那样),但是该区域也没有被对话框的绘制工作覆盖. -我正在考虑删除WS_CLIPCHILDREN,但是我相信这将导致控件被完全绘制,因此,请再次闪烁.

Additions: - I have tried making the BkMode of the controls to be TRANSPARENT, and even use a NULL_BRUSH. All this together with ON_WM_CTLCOLOR. What I got is simply a dialog with holes, and in those holes are the control text. In other words, instead of the control's background simply weren't drawn (as expected from NULL_BRUSH), but that area wasn't covered by the dialog's paint job either. - I am thinking of removing WS_CLIPCHILDREN, but I believe that will cause the controls to be drawn over anyway, so, flicker again.

推荐答案

您尝试过SetRedraw()吗?您可以为子窗口调用SetRedraw(FALSE),以便它们不会在每次更改父窗口时自动更新,并且在父编辑完成后,您最终可以为子窗口调用SetRedraw(TRUE)-并可能在那时无效,以便它们更新自己只有一次.

Did you try SetRedraw()? You can call SetRedraw( FALSE) for child windows so they don't update themselves every time you change the parent and when parent editing is complete you can finally call SetRedraw(TRUE) for childs - and perhaps invalidate at that time so they update themselves only once.

这篇关于MFC:如何避免在子控件更新中闪烁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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