COleDataSource - 设置拖拽在应用程序之间删除数据

发布于 2024-08-13 16:46:26 字数 297 浏览 8 评论 0原文

我正在处理的一些代码使用COleDataSource::CacheGlobalData,将指向为文本分配的某些内存的 HGLOBAL 作为 CF_TEXT 传递。我还想添加一个数值,以便放置目标可以访问文本或数值。

这怎么能轻易做到呢?可以使用不同的 CF_ 值进行第二次 CacheGlobalData 调用吗?由于我只想传递一个整数(DWORD),我可以避免分配一个混乱的 HGLOBAL 吗?

或者我是否必须将要发送的所有数据编码到单个内存块中? CacheGlobalData 是否只允许将一个对象附加到拖动事件?

Some code I am working on uses COleDataSource::CacheGlobalData, passing as CF_TEXT an HGLOBAL pointing to some memory allocated for the text. I want to also add a numeric value, so ythe drop-target can access either the text or numeric values.

How can this easily be done? Can a 2nd CacheGlobalData call be made with a different CF_ value? And since I only want to pass an integer (DWORD) can I avoid having to allocate a messy HGLOBAL?

Or do I have to encode all the data i want to send into a single chunk of memory? Does CacheGlobalData only let be attach one object to the drag event?

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

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

发布评论

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

评论(1

闻呓 2024-08-20 16:46:26

您可以多次调用 CacheGlobalData。对于每种剪贴板格式,剪贴板存储 CacheGlobalData 设置的最后一个值。例如,当您拖动一段文本时,IE 以 CF_UNICODETEXT、CF_TEXT 和 CF_HTML 格式存储数据。一般来说,应用程序应该提供尽可能多的格式的数据,以便更多的应用程序可以识别这些数据。

为了避免往返过程中数据丢失,应首先将包含最多信息的剪贴板格式放置在剪贴板上,然后放置描述性较少的格式。例如,首先是 CF_HTML,其次是 CF_UNICODETEXT,最后是 CF_TEXT。

您可能需要注册自己的数值格式,并修改可以理解您自己的格式的放置目标应用程序。所有标准格式均不采用数值。

剪贴板数据必须存储在全局内存中。如果您不喜欢这样,您可以传递 NULL 并处理 WM_RENDERFORMAT 或 WM_RENDERALLFORMATS 消息以在需要时提供数据,但对于 DWORD 来说这是不值得的。

You can call CacheGlobalData multiple times. For each clipboard format, the clipboard stores the last value set by CacheGlobalData. For example, IE stores data in CF_UNICODETEXT, CF_TEXT and CF_HTML formats when you drag a paragraph of text. Generally an application should provide data in as many formats as possible so more applications can recognize the data.

To avoid data lose in round trips, clipboard formats that contain the most information should be placed on the clipboard first, followed by less descriptive formats. For example, CF_HTML first, CF_UNICODETEXT second and CF_TEXT last.

You probably need to register your own format for the numeric value and modify your drop target application that can understand your own format. None of the standard formats take a numeric value.

Clipboard data must be stored in global memory. If you don't like that, you can pass NULL and handle WM_RENDERFORMAT or WM_RENDERALLFORMATS messages to provide data when needed, but for a DWORD it is not worth the effort.

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