Creating Drop Handlers
By default, files are not drop targets. You can make the members of a file class into drop targets by implementing and registering a drop handler.
If a drop handler is registered for a file class, it is called whenever an object is dragged over or dropped on a member of the class. The Shell manages the operation by calling the appropriate methods on the handler's IDropTarget interface.
The general procedures for implementing and registering a Shell extension handler are discussed in Creating Shell Extension Handlers. This document focuses on those aspects of implementation that are specific to drop handlers.
- Registering Drop Handlers
- Implementing Drop Handlers
Registering Drop Handlers
Drop handlers are registered under this file class subkey.
Create a subkey of DropHandler named for the handler, and set the subkey's default value to the string form of the handler's class identifier (CLSID) GUID. For a general discussion of how to register Shell extension handlers, see Creating Shell Extension Handlers.
The following example illustrates registry entries that enable a drop handler for an example .myp file class.
(Default) = MyProgram Application
Implementing Drop Handlers
Like all Shell extension handlers, drop handlers are in-process Component Object Model (COM) objects implemented as DLLs. They export two interfaces in addition to IUnknown: IPersistFile and IDropTarget.
The Shell initializes the handler through its IPersistFile interface. It uses this interface to request the handler's CLSID and provides it with the file's name. For a general discussion of how to implement Shell extension handlers, including the IPersistFile interface, see Creating Shell Extension Handlers.
Once the drop handler is initialized, the Shell calls the appropriate method on the handler's IDropTarget interface.