启用 XP 视觉主题/视觉样式会降低性能

发布于 2024-08-13 03:48:16 字数 649 浏览 2 评论 0原文

在尝试使旧的 C++Builder / Delphi 应用程序的外观现代化时,我启用了视觉主题 (视觉风格),并对添加的性能热门主题感到惊讶。例如,对于我们的主要设置页面(一个 11 个选项卡、200 个控件的怪物对话框,由于开发时间和再培训成本的原因,我们现在不想重做):

  • 未启用主题:~0.1 秒< /strong> 构建表单及其控件(通过 QueryPerformanceCounter 测量),从单击菜单项到显示表单需要 ~0.9 秒(通过秒表测量)。最终用户并不真正注意到。
  • 启用主题后:~0.6 秒构建表单及其控件,~1.5 秒从单击菜单项到显示表单。对于最终用户来说非常明显。

我在 Windows XP 桌面和 Windows 7 虚拟机上都得到了类似的结果。

我意识到我可以采取一些步骤来改进这种特殊情况(例如延迟加载对话框的选项卡或完全重新设计它),但是主题是否通常会增加如此明显的性能影响?是否有任何简单的建议可以避免这种性能影响?

While trying to modernize the appearance of an old C++Builder / Delphi application, I enabled visual themes (visual styles) and was surprised at just how much of a performance hit themes added. For example, for our primary setup page (an 11-tab, 200-control monster dialog that we don't want to redo right now for reasons of development time and retraining costs):

  • Without themes enabled: ~0.1 sec to construct the form and its controls (as measured by QueryPerformanceCounter), ~0.9 sec from clicking the menu item to the form being shown (as measured by stopwatch). Not really noticeable to the end user.
  • With themes enabled: ~0.6 sec to construct the form and its controls, ~1.5 sec from clicking the menu item to the form being shown. Very noticeable to the end user.

I get similar results on both a Windows XP desktop and a Windows 7 VM.

I realize that there are steps I could take to improve this particular case (such as lazily loading the dialog's tabs or redesigning it completely), but is it typical for themes to add such a noticeable performance hit? Are there any easy suggestions for avoiding this performance hit?

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

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

发布评论

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

评论(2

迷你仙 2024-08-20 03:48:16

哇。我不确定我是否曾经在一个表单上拥有 200 个控件。这里有一些建议。

  • 这可能是一种特殊情况,您希望在应用程序启动时创建一次对话框并在需要时显示它,而不是按需创建它。

    这可能是

  • 我还会查看构造函数或 OnShow 事件中发生的情况。您是否填充了 BeginUpdate/EndUpdate 具有优势的任何列表?

  • 您在 OnResize 事件或类似事件中是否有任何代码被多次触发,可以等到表单创建后运行一次?

  • 您使用什么类型的控件?如果一种类型的控件绘制特别慢,您也许可以将其替换为绘制速度更快的控件。不过,这需要一些测试。

Wow. I'm not sure I've ever had 200 controls on a single form. Here are a couple of suggestions.

  • This might be a special case where you want to create the dialog once when the application starts and display it when needed instead of creating it on demand.

  • I'd also look at what's going on in the constructor or OnShow event. Are you populating any lists where BeginUpdate/EndUpdate would be an advantage?

  • Do you have any code in an OnResize event or similar that gets fired more than once that could wait until after the form is created and be run once?

  • What kind of controls are you using? If one type of control paints particularly slowly, you might be able to replace it with one that paints more quickly. This would require some testing, though.

花开雨落又逢春i 2024-08-20 03:48:16

您可以尝试在控件上打开双缓冲,我们有很多相同的行为,并且通过这种方法在一定程度上加快了速度,但在采用应用程序主题支持之前并没有达到性能。

You could try and turn on doublebuffering on the controls, we had much the same behaviour, and it was somewhat speeded up by this approach, but didn't approach the performance before adopting application theming support.

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