避免在调整大小时移动其控件的对话框上出现闪烁 [英] Avoid Flickering on a dialog that moves its controls on resize

查看:128
本文介绍了避免在调整大小时移动其控件的对话框上出现闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个弹出对话框(CDialog),用于处理WM_CTLCOLOR消息以使其自身着色.它具有一些使用OwnerDraw进行绘制的控件(例如位图按钮).它还具有一个控件,该控件显示的图像大小最多占对话框的70%.

当用户调整对话框的大小时,对话框中的某些控件应重新放置(而不是重新调整大小). 这还涉及在对话框中重新调整图像的大小.由于重新调整图像的大小会使整个过程变慢,因此控件的单独重新放置会引起闪烁的视觉效果.

我需要摆脱这些.一种想法是将控件作为中间对话框的子级,而中间对话框是原始弹出对话框的子级.因此,当调整大小时,我只能重新调整对话框的位置,而不必单独移动每个控件. (重新定位仅在一个方向(x y)上发生,因此移动中间对话框应该就足够了.

由于涉及一些编码工作,因此在进行这种操作之前,我需要回答以下问题:

  • 这项工作会吗?
  • 如果是,此方法涉及的复杂性是什么?
  • 有更好的方法吗?

请帮助!

解决方案

它可能会起作用,但是您应该尝试以前不会更改控件层次结构的解决方案,因为它还会产生其他细微的后果(焦点,制表符顺序,消息通知等).

尝试以下一项或全部:

  • 使用BeginDeferWindowPos/DeferWindowPos/EndDeferWindowPos函数移动子项.
  • 在对话框中设置WS_CLIPCHILDREN样式标志.
  • 在对话框中设置WS_EX_LAYERED扩展样式标志.

I have a popup dialog( CDialog ) that handles WM_CTLCOLOR message to color itself. It is having some controls (like bitmap buttons) that draws themselves using OwnerDraw. It is also having a control that displays an image with size that takes up to 70% of the dialog.

When user re-sizes the dialog, some of the controls in the dialog should be re-positioned (not re-sized). It also involves re-sizing of the image inside the dialog. As the re-sizing of image makes the whole process slow, individual re-positioning of the controls are causing a visual effect of flickering.

I need to get rid of these. One idea is to put the controls as the children of an intermediate dialog that is the child of the original popup dialog. So, when there is a re-size, I can re-position the dialog only instead of moving each controls individually. (Re-position happens only in one direction (x or y), so moving the intermediate dialog should be enough.

As it involves some coding effort, before going this way, I need answers to the following questions:

  • Will this work?
  • If yes, whats the complexity involved in this method?
  • Is there a better way?

Please help!

解决方案

It will probably work, but you should try solutions that don't alter your control hierarchy before, because it has other subtle consequences (focus, tab order, message notifications, etc).

Try one or all of the following:

  • Use BeginDeferWindowPos/DeferWindowPos/EndDeferWindowPos functions to move the children.
  • Set the WS_CLIPCHILDREN style flag in the dialog.
  • Set the WS_EX_LAYERED extended style flag in the dialog.

这篇关于避免在调整大小时移动其控件的对话框上出现闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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