开发者

MFC/OLE Drag & Drop - freeing Globally allocated memory

开发者 https://www.devze.com 2022-12-13 17:13 出处:网络
If using COleDataSource & COleDataObject, you allocate some global memory for each clipboard data format you wish to store data in the drag\'n\'drop operation. In the drop code, you query if the o

If using COleDataSource & COleDataObject, you allocate some global memory for each clipboard data format you wish to store data in the drag'n'drop operation. In the drop code, you query if the object has data in the format(s) you want and can then access & free that memory.

But a开发者_高级运维s a drop-target you can't know all the formats that might have data associated by the drag-source. So how can you clear all the memory allocated for the drag for every format?

In fact, am I supposed to manually free this data on the drop, or let MFC/Ole do it automatically?


Once you pass the handle to the COleDataSource, it owns the memory, not you. You don't need to free the global memory.

You are supposed to enumerate available data formats in the COleDataObject object using BeginEnumFormats and GetNextFormat until you find one that you are interested in. For example, if you understands CF_HTML, you don't need to handle CF_UNICODETEXT or CF_TEXT unless the user instructed you to discard the HTML formating and only make a text-only drop/paste.

0

精彩评论

暂无评论...
验证码 换一张
取 消