IFileOperation 和进度对话框
所以,我正在研究这个 shell 命名空间扩展,它可以像文件夹一样处理一种 ZIP 文件(我们称之为 ZOP)。 一切就绪,文件操作通过 IFileOperation 和 IStream 进行处理。
问题是,将文件复制到我的虚拟 ZOP 文件夹中时,调用 IStream::Commit 并不简单,并且可能会花费大量时间,因此我想向用户提供额外的反馈(并且允许她取消操作)。
我已经有了一个进度回调机制,该机制会在提交流时启动。我现在所做的是一个自定义对话框,包括一个进度条,每当调用 IStream::Commit
时都会弹出该对话框。
但是,我似乎找不到标准进度对话框的 hWnd
,以便我的对话框可以是模态的(这意味着我的对话框可以被进度对话框本身隐藏,这违背了我的目的对话)。
我可以采用 IFileOperation::SetProgressDialog 方式,创建通往 IOperationsProgressDialog 的桥梁,但我仍然需要执行一些脏代码才能从流中找到进度条还没有创建 - 我能想到的传递数据的方法就是 TLS,天哪,我讨厌这个解决方案,类似于使用全局变量。
关于检索窗口句柄或子类化标准对话框的想法?
注意:我观察到,有时对于相对较短的操作,标准对话框会在流刷新后出现。这也很不酷,因为我的自定义对话框甚至在操作似乎开始之前就出现并消失。
更新:我使用 EnumWindows/FindWindowEx 找到了进度窗口,因为该窗口具有带有 DirectUIHWND
的 Dialog
类> 孩子。有趣的是,当使用 DialogBoxParam() 实例化我的对话框时(在与 IStream::Commit() 不同的线程中),调用甚至在我的对话框显示之前就挂起,因为它卡在 NtUserCallHwndParamLock
中>。
so, I am working on this shell namespace extension that handles a kind of ZIP file (let's call it ZOP) like a folder.
Everything is in place, and file operations are processed through IFileOperation
and IStream
.
The thing is, when copying a file into my virtual ZOP folder, calling IStream::Commit
is not trivial, and can take significant time, so I'd like to provide additional feedback to the user (and allow her to cancel the operation).
I already have a progress callback mechanism that kicks in when the stream is committed. What I've done for now is a custom dialog, including a progress bar, that pops up whenever IStream::Commit
is called.
However, I can't seem to find the hWnd
of the standard progress dialog so that mine can be modal (which means that my dialog can be hidden by the progress dialog itself, which defeats the purpose of my dialog).
I could go the IFileOperation::SetProgressDialog
way, creating a bridge to IOperationsProgressDialog
, but I'd still have to do some dirty code to find the progress bar from a stream I've not created - all I can think of to pass data around is the TLS, and boy do I hate this solution, akin to using a global variable.
Thoughts about retrieving the window handle or subclassing the standard dialog ?
Note: I've observed that sometimes, for relatively short operations, the standard dialog appears after the stream is flushed. Which is uncool too, as my custom dialog appears and goes away even before the operations seems to start.
Update: I've found the progress window using EnumWindows/FindWindowEx as the window has the Dialog
class with a DirectUIHWND
child. The funny thing is, when instantiating my dialog using DialogBoxParam() (in a distinct thread from IStream::Commit()), the call hangs even before my dialog is displayed, as it is getting stuck in NtUserCallHwndParamLock
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Sounds like a job for spy++, get the class name of the window who's hwnd your looking for and call FindWinow or FindWindowEx.