Chapter 7. Drop Handlers

Chapter 7. Drop Handlers

Drop handlers allow file objects to become drop targetsthat is, to define a custom behavior when one or more files are dropped on them. When a file is dropped on another file, the handler is provided with the names of both the target and source file(s). The files can then be processed in any manner appropriate to the situation. Consider the popular WinZip archive program. When a file is dropped onto an existing .zip file, it is added to the archive. This behavior is accomplished with the help of a drop handler.

Drop handlers are easy to implement. They implement two interfaces ( IDropTarget and IPersistFile ), one of which is already familiar to us.

The drop handler we will implement in this chapter offers no practical functionality other than to show you how one works. It will allow you to drop one or more files onto a .rad file object. The drop handler will report the names of the source file(s), the target file, and keyboard/mouse states.