Article # 259, added by Geoworks, historical record
| first |
previous |
index |
next |
last |
Using ClipboardEndQuickTransfer correctly.
Q. I am trying to implement drag and drop into my program, and I want to get the name of the transfer item. However, when I use this code to do it, I get a VM_HANDLE_NOT_IN_USE error: TransferBlockID transferID; /* File/Block of item header. */ MemHandle itemMem; /* Mem block for item header. */ ClipboardItemHeader * itemPtr; /* Pointer to item header. */ ClipboardEndQuickTransfer( PasteCommon( CIF_QUICK, textOD, pself->GDI_fileHandle, &itemBlock ) ); transferID = ClipboardGetQuickItemInfo(); itemPtr = VMLock( FileFromTransferBlockID( transferID ), BlockFromTransferBlockID( transferID ), &itemMem ); /* * Add the new item to the map block. */ @call self::MSG_SB_DOCUMENT_ADD_ITEM( itemBlock, itemPtr ); VMUnlock( itemMem ); A. Here is how to do it: ClipboardQuickNotifyFlags retFlags; /* Returned from PasteCommon. */ retFlags = PasteCommon( CIF_QUICK, textOD, pself->GDI_fileHandle, &itemBlock ); transferID = ClipboardGetQuickItemInfo(); itemPtr = VMLock( FileFromTransferBlockID( transferID ), BlockFromTransferBlockID( transferID ), &itemMem ); /* * Add the new item to the map block. */ @call self::MSG_SB_DOCUMENT_ADD_ITEM( itemBlock, itemPtr ); VMUnlock( itemMem ); ClipboardEndQuickTransfer( retFlags ); (The PasteCommon function is in the ClipSamp sample program on the GEOS SDK disk.) The reason this code fragment works is that it is getting the information from the item header BEFORE calling ClipboardEndQuickTransfer, which destroys that header. So, in the previous fragment, we were calling for a VM block that was just freed, and thus we get the error message.