问题描述
我正在处理的程序的其中一个功能是从主窗口拖动对象并将其放在Windows资源管理器中作为文件的功能。
为此,我们覆盖 COleDataSource :: OnRenderGlobalData()
,当格式为 CF_HDROP
,我们将每个对象保存为一个文件。当对象数量较小时,此功能正常。但是,由于我们正在努力支持企业级数量的对象,我们看到很大的延迟,有时会导致挂起或最终崩溃,当用户尝试将很多对象从我们的应用程序拖到Windows资源管理器中。
我的猜测是,这是因为 OnRenderGlobalData()
被多次调用,当然,每次它必须循环通过被拖动的对象并将它们保存为文件。
我正在研究覆盖 OnRenderFileData()
,但问题在于它一次只处理一个文件。
有没有什么可以的当用户尝试将大量对象拖动到Windows资源管理器时,最好将保存循环移动到仅在执行实际下降时才能执行一次的地方,加快我们的应用程序?
不要创建文件,拖动在下载时生成的虚拟数据。提供CFSTR_FILEGROUPDESCRIPTOR和CFSTR_FILECONTENTS。 。
One of the features that the program that I'm working on is the ability to drag objects from its main window and drop them onto Windows Explorer as files.
To do this, we override COleDataSource::OnRenderGlobalData()
and, when the format is CF_HDROP
, we save each object as a file. This works fine when the number of objects is small.
However, as we're now working on supporting enterprise level amounts of objects, we're seeing big delays, sometimes leading to hangs or eventual crashes, when the user tries to drag a lot of objects from our application into Windows Explorer.
My guess is that this is happening because OnRenderGlobalData()
is being called quite a number of times, and of course, each time it has to loop through the objects that are being dragged and save them as files.
I was looking into the idea of overriding OnRenderFileData()
, but the problem with that is that it only deals with one file at a time.
Is there any way that I can speed up our application when the user tries to drag a lot of objects onto Windows Explorer, preferably by moving the save loop to a place where it can be executed only once when the actual drop takes place?
Instead of creating files, drag virtual data that is generated at drop time. Offer CFSTR_FILEGROUPDESCRIPTOR and CFSTR_FILECONTENTS. Here's an example.
这篇关于如何拖&丢弃大量文件而不征收系统资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!