WS_EX_COMPOSITED的无闪烁选项卡控件 [英] flicker free tab control with WS_EX_COMPOSITED
问题描述
我有一个使用WTL 8.1开发的Windows XP SP3的VS2008 C ++应用程序.我的应用程序包含一个选项卡控件,当调整应用程序边框的大小时,该控件会闪烁.
I have a VS2008 C++ application for Windows XP SP3 developed using WTL 8.1. My application contains a tab control that flickers when the application border is resized.
我的窗口层次结构如下:
My window hierarchy looks like this:
CFrameWindowImpl CMainFrm
|-CSplitterWindow Splitter
|-CTabView Configuration Tabs
| |-CDialogImpl Configuration View 1
| |-CDialogImpl Configuration View 2
| |-CDialogImpl Configuration View 3
|-CDialogImpl Control View
我正在尝试的解决方案是使CFrameWindowImpl
派生类使用WS_EX_COMPOSITED
样式,并且其下面的所有窗口都使用WS_EX_TRANSPARENT
样式.不幸的是,这使得选项卡控件按钮显示为空白的黑条,而所有配置视图"的控件都根本不显示.
The solution I'm trying is to make the CFrameWindowImpl
derived class use the WS_EX_COMPOSITED
style and all windows beneath it use the WS_EX_TRANSPARENT
style. Unfortunately, this makes the tab control buttons show as an empty black bar and the controls of any Configuration View to not show at all.
如果我删除了WS_EX_COMPOSITED
和WS_EX_TRANSPARENT
样式,则窗体会正确显示,但是CTabView
及其下面的所有内容在调整大小时都会闪烁.
If I remove the WS_EX_COMPOSITED
and WS_EX_TRANSPARENT
styles, the form displays properly, but the CTabView
and everything beneath it flickers horribly when resized.
我需要更改什么以消除闪烁并正确绘制控件?
What do I need to change to eliminate the flicker and draw the controls properly?
谢谢, PaulH
得到它的工作.我按照Mark Ransom的建议删除了所有WS_EX_TRANSPARENT
样式.我将WS_EX_COMPOSITED
样式仅放在CTabCtrl
(包含在CTabView
中)上.其他控件根据需要通过WTL::CDoubleBufferImpl<>
获得双缓冲.
Got it working. I removed all the WS_EX_TRANSPARENT
styles per Mark Ransom's suggestion. I put the WS_EX_COMPOSITED
style on only the CTabCtrl
(contained within the CTabView
). Other controls get double-buffering as needed through WTL::CDoubleBufferImpl<>
.
推荐答案
一个窗口闪烁,因为它在绘制之前已被擦除.为了消除这种情况,您需要完全禁用对窗口的擦除,并使用双重缓冲-将窗口内容绘制到位图中,然后将位图复制到窗口中.因为位图包含了包括背景在内的全部内容,所以不再需要擦除.
A window flickers because it gets erased before it's drawn. To eliminate this you need to disable erasing of the window entirely and use double buffering - draw the window contents into a bitmap, then copy the bitmap to the window. Because the bitmap contains the entire contents including the background, there's no need to erase anymore.
看起来WS_EX_COMPOSITED将自动处理双缓冲,但是您可能仍需要使用NULL背景画笔和/或处理WM_ERASEBKGND消息.
It looks like WS_EX_COMPOSITED will handle the double buffering automatically, but you still probably need to use a NULL background brush and/or handle the WM_ERASEBKGND message.
这篇关于WS_EX_COMPOSITED的无闪烁选项卡控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!