Flickering UI problems - what causes the DWM in windows 7 to decide to refresh immediately upon calling SetWindowPos?
I have a custom tabbed style control, and internally it works by showing or hiding the relevant page when you click on a tab.
The basic order of things that happen when you click a tab is
- Bring relevant page to front
- Show relevant page (by calling SetWindowPos with the appropriate flags)
- Hide the old page that we just covered up
- Repaint the window
Some of my tabs are rendered with DirectX. Under Windows XP everything works fine and there's no flicker when you switch between tabs. Under Windows 7 though (or Vista), the call to SetWindowPos in step 2 redraws the window, and there's a flash of uninitialized pixels before step 4, usually whatever was on the desktop before my app started running.
This only happens with the DirectX pages, but I'm not sure what it is about DirectX that would cause this, if anything - there are other differences between the pages as well, that was just the obvious pattern. I'm not sure if this is a real clue or a red herring.
The GDI pages don't repaint until step 4. I stepped through the code and checked - it's not just that the DWM uses a correctly cached bitmap in step 2 - it really doesn't repaint at all until step 4.
That's the background info, but at the moment I'm not sure how to tackle this specific problem, so my question is more general:
开发者_运维技巧What are all the things that can affect SetWindowPos's decision to repaint or not?
精彩评论