7.1 How Drop Handlers Work

only for RuBoard - do not distribute or recompile

7.1 How Drop Handlers Work

When one file (the source file) is dragged over another file (the target file), the shell checks under the target file's application identifier key to see if a drop handler has been registered for that particular file class. This key is in the following location ( assuming we are talking about .rad files):

 HKEY_CLASSES_ROOT\     radfile\         shellex\             DropHandler = {CLSID} 

As you can see from the registry setting, there can be only one drop handler registered for a file class.

If a drop handler for the target file exists, the shell will load it and pass it the name of the target file through IPersistFile::Load . Once this occurs, the shell will start calling methods on the IDropTarget portion of the handler object.

The drop handler will be notified via IDropTarget several times during the drag-and-drop operation: once when the files enter the target area ( IDropTarget::DragEnter ), once when the files exit the target area ( IDropTarget::DragLeave ), and every time the mouse is moved within the target area ( IDropTarget::DragOver ). There is also a notification when the files are dropped ( IDropTarget::Drop ).

As the drop operations occur, the handler is given the opportunity to notify the shell of the drop operation status. This allows the shell to visually notify the user of what is happening by changing the cursor. For instance, if our drop handler only accepts .txt files and we drag a .zip file over the target, the drop handler can tell the shell that the operation will not work. The shell can then display the No Drop cursor (see Figure 7.1) to inform the user that files of type .zip are not acceptable for this particular drop target.

When a successful drop operation occurs, the shell will pass the name of the source files via an IDataObject interface to the drop handler. As you saw in Chapter 5, it's a simple matter to extract the names of the files from the data object and process the files in a manner befitting the situation.

only for RuBoard - do not distribute or recompile


Visual Basic Shell Programming
Visual Basic Shell Programming
ISBN: B00007FY99
EAN: N/A
Year: 2000
Pages: 128

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net