Control flyer without tabs with WS_EX_COMPOSITED

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 frame size of the application changes.

My window hierarchy is as follows:

CFrameWindowImpl CMainFrm |-CSplitterWindow Splitter |-CTabView Configuration Tabs | |-CDialogImpl Configuration View 1 | |-CDialogImpl Configuration View 2 | |-CDialogImpl Configuration View 3 |-CDialogImpl Control View 

The solution I'm trying to do is make the CFrameWindowImpl class using the WS_EX_COMPOSITED style, and all the windows below it use the WS_EX_TRANSPARENT style. Unfortunately, this leads to the fact that the tab control buttons are displayed as an empty black bar, and the controls of any kind of configuration are not displayed at all.

If I delete the WS_EX_COMPOSITED and WS_EX_TRANSPARENT , the form displays correctly, but the CTabView and everything below it flickers when resizing.

What do I need to change to eliminate flicker and draw the controls correctly?

Thanks PaulH


Edit: This worked. I removed all the WS_EX_TRANSPARENT styles for the Mark Ransom proposal. I placed the WS_EX_COMPOSITED style only in CTabCtrl (contained in CTabView ). Other controls receive double buffering as needed through WTL::CDoubleBufferImpl<> .

+2
c ++ windows flicker wtl
source share
3 answers

The window flickers because it erases before it is drawn. To fix this, you need to completely disable window erasure and use double buffering - draw the contents of the window into a bitmap, and then copy the bitmap to the window. Since the bitmap contains all the content, including the background, you no longer need to erase it.

It looks like WS_EX_COMPOSITED will handle double buffering automatically, but you still probably need to use the NULL background brush and / or process the WM_ERASEBKGND message.

+1
source share

What is not mentioned in MSDN is that the desktop window manager, a component that intercepts window painting in Windows Vista and 7 to execute the desktop composition necessary to obtain the aerosone effect, DOES NOT implement WS_EX_COMPOSITED.

This means that all the work you put into working this style for working with XP is doomed to become inappropriate in Vista or later.

Another problem with WS_EX_COMPOSITED is why it was an optional style and not the default for XP: double buffering only raises the picture executed during the BeginPaint / EndPaint block of the parent window. Many, even standard controls, draw outside their WM_PAINT handlers, and as a result, the bunker receives only a partial color.

Unfortunately, the result is that the only way to β€œeliminate” flickering in your own API applications is to try to minimize it: WS_CLIPCHILDREN and WS_CLIPSIBLINGS can help if you don't have overlapping controls β€” so that each control area is drawn only once , And make sure that the main dialog does not fill the flood in WM_ERASEBKGND

+2
source share

In my experience, it is not possible to use double buffering for everything that contains child controls (unless they fully support WM_PRINT, which is not the case).

0
source share

All Articles