在启用主题的Windows XP / Vista中的TAnimate将无法正常工作 [英] TAnimate in Windows XP/Vista with themes enabled won't work

查看:114
本文介绍了在启用主题的Windows XP / Vista中的TAnimate将无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

同事已经使用自定义AVI来指示在更长时间的操作中进行多年。它总是工作正常。

A coworker has been using a custom AVI to indicate progress during some longer operations for years. It's always worked fine.

最近他决定从Delphi 7迁移到Delphi 2007,部分原因是为他的应用程序提供主题支持。 (我们终于得到了大多数人,但并不是全部在XP上运行。)动画停止工作。禁用主题使其重新工作。

Recently he decided to move from Delphi 7 to Delphi 2007, in part to get theme support for his applications. (We've finally got most people, but not all, running on XP.) The animation stopped working. Disabling themes makes it work again.

TAnimate是使用InitCommonControlsEx(ICC_ANIMATE_CLASS)创建的Windows动画控件的包装器。 MSDN文档说,如果您使用ComCtl32.dll版本6,则不支持该线程,因此请确保您的应用程序不会阻止用户界面或不会发生动画。显然,这是预期的行为。

TAnimate is a wrapper around the Windows Animation Control, created using InitCommonControlsEx(ICC_ANIMATE_CLASS). The MSDN documentation says that "If you are using ComCtl32.dll version 6 the thread is not supported, therefore make sure that your application does not block the UI or the animation will not occur." Obviously, this is the intended behavior.

有没有人有解决方法或替代这个问题的建议?他试图显示进度的处理不能很好地产生一个单独的线程,并且由于明显的原因Application.ProcessMessages也不是一个很好的解决方案。

Does anyone have a suggestion for a workaround or alternative to this problem? The processing he's trying to show progress for doesn't lend itself well to spawning a separate thread, and for obvious reasons Application.ProcessMessages is not a good solution either.

编辑:我给罗伯·肯尼迪授予这个问题的正确答案,因为a)他向雷蒙德的博客提供了关于这个话题的缺失的链接(双关语),以及b)因为当然把事情转到一个单独的线程正确的答案。

I'm awarding Rob Kennedy the correct answer to this question, because a) he provided the "missing link" (pun intended) to Raymond Chen's blog post on this topic, and b) because of course moving things to a separate thread was the proper answer.

这里的讽刺的是:他正在执行的阻止TAnimate的操作是我们使用的数据库引擎的索引操作(Advantage Database Server或ADS )。他没有提到当他来找我的问题。

The ironic thing here: The operation he was conducting that blocked the TAnimate was an indexing operation for a database engine we use (Advantage Database Server, or ADS). He didn't mention that when he came to me with the problem.

ADS支持使用TAdsDataSet.AdsRegisterCallbackFunction和TAdsDataSet.AdsClearCallbackFunction方法进行回调。回调函数同时提供当前操作的进度(百分比)和通过函数的返回值取消操作的方法。所以整个问题呢就是这样呢?回调函数可用于更新进度条,该进度条向用户指示该应用未挂起。

ADS supports a progress callback using the TAdsDataSet.AdsRegisterCallbackFunction and TAdsDataSet.AdsClearCallbackFunction methods. The callback function is provided both the progress (in percent) of the current operation and a way to cancel the operation by means of the function's return value. So the entire question turns out to be moot; the callback function can be used to update a progress bar, which indicates to the user that the app isn't hung.

推荐答案

Raymond Chen已经写了这个。他没有' t甚至触及我通常认为的主要原因,即线程控件不能正常工作,这是线程不应该绘制与不同线程关联的窗口。

Raymond Chen has written about this. He doesn't even touch on what I usually think of as the primary reason that a threaded control wouldn't work well, which is that a thread shouldn't draw on a window associated with a different thread.

我鼓励你的同事重新考虑一下,使他决定不能把任务放在一个单独的线程上。阻止主用户界面线程不是一个好主意,无论是否有动画控件来掩盖无响应性。

I encourage your co-worker to revisit whatever it was that made him decide that he couldn't put the task into a separate thread. It's simply not a good idea to block the main UI thread, regardless of whether there's an animation control there to cover up the non-responsiveness.

这篇关于在启用主题的Windows XP / Vista中的TAnimate将无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆