为什么在 XP 上显示 DirectShow 窗口可能需要 WS_CLIPCHILDREN(但在 Vista 或 Windows 7 上则不需要)?

发布于 2024-08-24 18:50:20 字数 185 浏览 7 评论 0原文

我写了一个程序在一个窗口上播放MPEG视频(当然,DirectShow会打开自己的窗口作为该窗口的子窗口)。在 Windows Vista 和 7 上,该程序运行良好。但在 XP 上,只有当我在外部窗口(即不是 DirectShow 窗口)上设置 WS_CLIPCHILDREN 样式时,视频才可见。这是 XP 中的错误还是 Vista 中的某些模型更改?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鸠魁 2024-08-31 18:50:21

实际上,这听起来像是代码中的错误...

WS_CLIPCHILDREN 影响父窗口的绘制。更具体地说,它阻止它在其子项占据的区域中绘制。因此,如果您定期重新绘制父窗口并且未设置 WS_CLIPCHILDREN ,您最终会踩踏子窗口的显示...

至于为什么这可能会影响 XP 和不是 Vista 或 Win7,嗯...这只是一个猜测,但是 XP 上的许多视频播放器使用了大多数显卡提供的功能,称为“覆盖":本质上,窗口填充了一种关键颜色,然后硬件将其识别为指示屏幕上将显示视频的区域。由于窗口本身不会经常重新绘制(最初和调整大小时需要填充关键颜色,但不会为视频中的每一帧重新绘制),因此允许父级在其上绘制可能会严重造成混乱你的输出!

潜在的解决方案

  1. 在父窗口上使用 WS_CLIPCHILDREN。无论如何,这几乎总是一个好主意。

  2. 如果您的父窗口有自定义绘制代码,请修改它以手动避免在子窗口占用的区域上绘制。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文