CreateWindowEx() 在 Windows-7 上运行缓慢(有时)
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
既然您提到了
WS_POPUP
,它可能与CS_SAVEBITS
类样式(如果您要创建设置了WS_VISIBLE
的窗口)。Since you mentioned
WS_POPUP
, it could have something to do with theCS_SAVEBITS
class style if you're creating the windows withWS_VISIBLE
set.如果您想将其降回 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.