Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why might WS_CLIPCHILDREN be necessary for the display of DirectShow window on XP (but not Vista or Windows 7)?

I wrote a program to play MPEG video on a window (of course, DirectShow will open its own window as the sub-window of that window). On Windows Vista and 7, the program works fine. But on XP, the video is only visible when I set the WS_CLIPCHILDREN style on the outer window (i.e. not the DirectShow one). Is this a bug in XP or some model change in Vista?

like image 353
Middleware Avatar asked Feb 28 '23 10:02

Middleware


1 Answers

Actually, it sounds like a bug in your code...

WS_CLIPCHILDREN affects the drawing of the parent window. More specifically, it prevents it from drawing in the areas occupied by its children. So if you're re-drawing the parent on a regular basis and WS_CLIPCHILDREN isn't set, you'll end up stomping on the child window's display...

As for why this might affect XP and not Vista or Win7, well... This is just a guess, but many video players on XP used a feature provided by most video cards known as "overlays": essentially, the window was filled with a key color and this was then recognized by the hardware as indicating the area on screen where the video would be displayed. Since the window itself would not be repainted often (it would need to be filled with the key color initially and when resized, but wouldn't be repainted for every frame in the video), allowing the parent to draw over it could seriously mess up your output!

Potential solutions

  1. Use WS_CLIPCHILDREN on your parent window. This is almost always a good idea anyway.

  2. If you have custom painting code for your parent window, modify it to manually avoid drawing over the area occupied by the child.

like image 72
Shog9 Avatar answered May 16 '23 02:05

Shog9