delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
494 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi



Loremo - the 1.5 liter car coming in 2009




Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (0)


OLE Drag and Drop Delphi OverviewFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi 4.x (or higher)
Category:
COM+
Skill Level:
Scoring:
Last Update:
01/20/2003
Search Keys:
delphi delphi3000 article borland vcl code-snippet COM OLE Drag Drop
Times Scored:
3
Visits:
3451
Uploader: Herbert Poltnik
Company:
Reference: Graham Wideman
 
Question/Problem/Abstract:
OLE Drag and Drop Delphi Overview
Answer:



There is an excellent resource on the web on OLE drag and drop. See the full article at http://www.wideman-one.com/gw/tech/Delphi/dragdrop/DragDrop_OverView.htm

Orientation

There are plenty of reasons for you to want your application to be able to accept   drops from other applications. Often you may just want to accept or source a file or files, but at other times you want to be able to accept or source other items, and here's where the fun starts.  If you've looked into how to do that, you'll have run into the steep learning curve associated with getting into Microsoft's COM/OLE system.

Well, thankfully, a number of authors have recently tackled that topic, and laid down most of the path for us to follow. To really nail down the concepts, and see how OLE drag-and-drop works,  I decided to build some demo apps that would:

  • Demonstrate and clarify:
    • how an application prepares participate in OLE drag-and-drop
    • how to clean up at the end
    • several loose ends left by the references that I consulted.
  • Provide Browsing capability:
    • view the data formats that other source apps offer to drop.
    • the actual data content for each format.

Version applicability: This article applies to (and the software has been tested with) Windows NT 4 (SP3) and Windows 95. It uses techniques that have applied certainly since 1995, hence should work with NT 3.5x, and who knows, might even work with NT 5 and Windows 98!. The code is for Delphi 3, I expect it to work in Delphi 4, and it may also work with Delphi 2.

Drag and Drop Variations

There are at least three different drag-and-drop variations to think about:

Within-app drag-and-drop: Your app manages this any way you like, using the various drag and drop events provided with Delphi TControls. Since you have control over both ends of the transaction, you can move any kind of data you like.   You could use COM in the process, but you certainly don't have to.

Between-app drag-and-drop: The source and destination applications must each provide certain COM objects to manage the drag-time behavior, and to pass the data from one app to the other.  If you try to read the "raw" OLE documentation on how to do this, it looks daunting.  Fear not, Delphi makes it somewhat easier, and the third-party books, demos, and the demo I describe here show the way.  

Between-app drag-and-drop, Files Only: So-called CF_HDROP (clipboard-format, handle for dropping files). Accepting dropped files is a limited but often-useful subset of general drop-accept capability, so Windows provides a way to do this without requiring your app to know about COM.  Jim Mischel covers this in "High Performance Delphi 3"... but later concludes (and it looks about right to me) "What I found most surprising about [the OLE] drop target implementation is that it's less complicated than the [files-only implementation]". 

Pieces to Master

There are two main things to master:

  • How to work with COM objects.   For more info on this subject visit the "Understanding COM (OLE)..." reference in the Contents.
     
  • Understand the Sequence of Events in Drag and Drop: OLE Drag and Drop involves what at first seems a relatively complicated series of interactions between several COM objects, some on the source app side, and some on the target app side, several of which are rather confusingly named. It actually turns out that the mechanism is a pretty straightforward conversation, but you really need a diagram to follow it. I decided to sketch one out in the form of a UML-style sequence diagram.

With that said, proceed to try out the demo applications, or go to the Theory page... see Contents page.

Resources/References

  • Taylor, Mischel, Penman, Goggin, Shemitz: "High Performance Delphi 3 Programming" 1998
  • Cantu, Gooch, Lam: "Delphi Developer's Handbook"  1998
  • Brockschmidt: "Inside OLE 2" (first and second editions) 1994, 1995?





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment













 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
I. Siticov
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)