CreateWindowEx() 在 Windows-7 上运行缓慢(有时)

发布于 2024-10-01 18:34:01 字数 834 浏览 3 评论 0原文

我在 Windows-7(可能还有 Vista)上遇到了非常糟糕的性能问题,调用了 CreateWindowEx()。

我正在创建的一些窗口在 Windows-7 中比 XP 中花费的时间长。时间可能高达 15-25 毫秒,当您需要创建很多时,这个时间就很长了。 (XP 上的时间始终为 0-2 毫秒。)这是为什么?可以做什么?

所有窗口都是在同一个线程中创建的。有些是在窗口类中构建的,有些是我自己的。对我来说,似乎所有带有 WS_POPUP [编辑:和 WS_EX_TOOLWINDOW] 的窗口都会遭受这种延迟,而所有没有它的窗口则不会。 (但实际原因当然可能是其他一些属性。)这似乎适用于我的所有窗口,除了 RICHEDIT_CLASS 控件,它是唯一一个在 1-30 毫秒之间不一致变化的控件,但仅在 7 上。 谢谢!

[编辑:该应用程序受到创建主窗口时创建的许多(〜300)工具提示的影响最大,使用 gToolTip。我可以延迟工具提示的创建,直到显示窗口,但我还有其他“邪恶”窗口,并且我仍然想确切地了解发生了什么]

更新:我的工具提示问题得到了极大的改善。我从 CodeProject 使用的包装类不适合 [被调用 300 次,每个控件一次],因为它为每次调用创建一个新窗口。诀窍是创建一个工具提示窗口(针对每个弹出窗口),然后仅向每个控件发送一条 TTM_ADDTOOL 消息。

因此,性能得到了很大提高,但其他窗口仍然存在明显的滞后......

I am having quite bad performance problems on Windows-7 (and probably Vista), with calls to CreateWindowEx().

Some of the windows I am creating are taking much longer in Windows-7 than XP. Times can be as high as 15-25 ms which is a lot when you need to create many. (Times on XP are consistently 0-2 ms.) Why is this? and what can be done?

All windows are created in the same thread. Some are built in window-classes some are my own. To me it seems that all windows with WS_POPUP [EDIT: and WS_EX_TOOLWINDOW] suffer from this delay, and all windows without it don't. (But the actual cause could of course be some other property.) This seems to apply for all my windows, except a RICHEDIT_CLASS control, which is the only one which inconsistently varies between 1-30 ms, but only on 7.
Thanks!

[EDIT: The app suffers most from a many ( ~300 ) tool-tips created as the main window is created, using gToolTip. I could delay tooltip creation until the window is shown but I have other "evil" windows, and I would still like to understand exactly what is happening]

UPDATE: My issue with tool-tips is greatly improved. The wrapper-class I used from CodeProject was not suitable [for being called 300 times, once for each control], as it creates a new window for each call. The trick is to create one tool-tip window (for each pop-up) and then only send a TTM_ADDTOOL-message to it for each control.

So performance is much improved, but a noticable lag still remains for the other windows...

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

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

发布评论

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

评论(2

听不够的曲调 2024-10-08 18:34:01

既然您提到了 WS_POPUP,它可能与 CS_SAVEBITS 类样式(如果您要创建设置了 WS_VISIBLE 的窗口)。

CS_SAVEBITS (0x0800)

将被此类窗口遮挡的屏幕图像部分保存为位图。 ...这种样式增加了显示窗口所需的时间,因为系统必须首先分配内存来存储位图。

Since you mentioned WS_POPUP, it could have something to do with the CS_SAVEBITS class style if you're creating the windows with WS_VISIBLE set.

CS_SAVEBITS (0x0800)

Saves, as a bitmap, the portion of the screen image obscured by a window of this class. ... This style increases the time required to display the window, because the system must first allocate memory to store the bitmap.

沧笙踏歌 2024-10-08 18:34:01

如果您想将其降回 XP,请关闭 Aero。它的合成功能可以实现玻璃和实时缩略图等内容,但不是是免费的。

Turn off Aero if you want to dumb it down back to XP. Its compositing feature that enables stuff like glass and live thumbnails does not come for free.

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