检测何时在 MFC COleDataSource VS2008 中粘贴剪切数据

发布于 2024-11-01 11:07:02 字数 315 浏览 2 评论 0原文

我需要检测应用程序中的另一个应用程序/窗口何时粘贴到我之前设置的数据上,以便我可以将其从源窗口中删除。我发现 COleDataSource::DelaySetData 理论上 会执行此操作,并且在发生粘贴时会调用 COleDataSource::OnSetData,但我无法确定。 MSDN(通常)对此事含糊其辞,没有明确说明其中一种方式。我将使用自定义格式,而水格式是浏览器用于剪切/粘贴文件的格式。 所以问题是如何准确地(不是理论上)做到这一点。 我确实需要从窗口中删除这些项目当且仅当它们被粘贴到其他地方。

I need to detect when another application /window in my app does paste on my previously set data , so I can remove it from my source window. I have discovered that COleDataSource::DelaySetData theoretically does this and COleDataSource::OnSetData would get called when paste occurs, but I can not be sure. MSDN is (as usually) vague about this matter and does not clearly say one way or the other.I will be using an custom format and watever format is explorer using for cut/paste files.
So the question is how EXACTLY (not theoretically) can this be done.
I really need to remove the items from my window if and only if they are pasted somewhere else.

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

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

发布评论

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

评论(1

昔日梦未散 2024-11-08 11:07:02

你都做错了。当你剪切某些东西时,它应该立即被删除,如果需要恢复,你应该提供撤消功能。

剪贴板不是为双向信号传输而设计的。 DelaySetData适用于以不同格式提交大量数据的应用程序,因此它们只需要提供接收者所需的格式;使用它来检测何时发生粘贴依赖于副作用。有些剪贴板管理器可能会导致此操作失败。

You're doing it all wrong. When you Cut something it's supposed to be deleted immediately, and you should provide an undo function if it needs to be restored.

The clipboard was not designed for bidirectional signalling. DelaySetData is intended for applications which are submitting large amounts of data in different formats, so that they only need to provide the format which is required by the receiver; using it to detect when a paste occurs is relying on a side effect. There are clipboard managers which might make this fail.

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