Drop source example: Drop a TUOTextSource and a TListView on your form. Set the DragMode property of TListView to dmAutomatic, and connect the TUOTextSource's DonorComponent property to the TListView. Finally, in the OnStartDrag event of the TListView, enter the code "UOTextSource1.Execute; abort;"
That's it! The TListView is now a fully functioning OLE drag source, and the text supplied to a drop target like Excel or Word will be the text of the currently selected item and its SubItems, separated by tabs (drop onto Excel to see the effect)! If the TListView were multi-select, all of the selections would be dropped. In general, TUOTextSource tries to do "the right thing" with the DonorComponent; if you prefer, of course, you can still set the text to be dropped explicitly yourself. The DonorComponent can be any TComponent descendant.
Drop target example: Drop a TUOTextTarget and a TMemo on your form. On the TUOTextTarget, connect the AcceptorControl property to the TMemo and set the AcceptTextFormat property to [dtfText, dtfFiles]. Finally, in the OnDrop event of the TUOTextTarget, write the code that does what you want with the dropped text, e.g., "Memo1.Lines.Add(dropText);"
That's it! The TMemo can now accept drops of text from Excel or Word, or lists of files from Explorer!
You can browse the code for other sample applications here to see how straightforward it is to incorporate OLE drag and drop into your own applications, without first having to download and experiment with the components.Full context-sensitive help is provided.
Last modified: Monday, August 24, 1998 10:07:09 PM