如何拖动&在不占用系统资源的情况下删除大量文件? [英] How to drag & drop lots of files without taxing system resources?

查看:14
本文介绍了如何拖动&在不占用系统资源的情况下删除大量文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发的程序的一个功能是能够从其主窗口拖动对象并将它们作为文件拖放到 Windows 资源管理器中.

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.

为此,我们重写 COleDataSource::OnRenderGlobalData() 并且当格式为 CF_HDROP 时,我们将每个对象保存为文件.当对象数量很少时,这可以正常工作.

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.

但是,由于我们现在正致力于支持企业级数量的对象,因此当用户尝试将大量对象从我们的应用程序拖到 Windows 资源管理器中时,我们会看到很大的延迟,有时会导致挂起或最终崩溃.

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.

我猜这是因为 OnRenderGlobalData() 被调用了很多次,当然,每次它都必须遍历被拖动的对象并保存它们作为文件.

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.

我正在研究重写 OnRenderFileData() 的想法,但问题是它一次只处理一个文件.

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.

当用户尝试将大量对象拖到 Windows 资源管理器上时,有什么方法可以加快我们的应用程序的速度,最好是通过将保存循环移动到在实际放置时只能执行一次的地方?

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?

推荐答案

不要创建文件,而是拖动拖放时生成的虚拟数据.提供 CFSTR_FILEGROUPDESCRIPTOR 和 CFSTR_FILECONTENTS.这是一个例子.

Instead of creating files, drag virtual data that is generated at drop time. Offer CFSTR_FILEGROUPDESCRIPTOR and CFSTR_FILECONTENTS. Here's an example.

这篇关于如何拖动&在不占用系统资源的情况下删除大量文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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