|
|
|
Examples
DropMaster comes with a collection of more than 40 example projects that demonstrate
the extreme power of the component's capabilities. The following table
briefly describes the various example applications that are provided and installed along with DropMaster. Examples are included for both
Delphi and C++Builder.
The example applications demonstrate the features of the DropMaster
components with real-world examples. They also represent the results of
extensive research into the drag and drop behavior of many popular
commercial applications. The location of each example application in the DropMaster installation is
also provided. The Demos directory is located in the DropMaster
installation directory.
For some examples, we have provided a compiled version of the program
for you to download and execute.
|
|

|
Delphi Examples
Clipboard
ClipboardTest
| Location |
Demos\Delphi\Clipboard\ClipboardTest.dpr |
| Description |
Demonstrates manipulating "fancy"
clipboard formats using the helper functions in the DMUtil unit.
While this is not directly related to drag-and-drop, the universal
data transfer mechanism underlies both, so there are many concepts
in common. We show the specific example of putting file names in the
clipboard so that the shell (Explorer) will offer the choice to
paste them, or paste them as shortcuts. The converse - getting file
names from the clipboard, put there by a copy operation in the shell
- is also demonstrated. |
| Download |
ClipboardTest.zip  |
Custom Formats
AcceptMany
| Location |
Demos\Delphi\CustomFormats\AcceptMany.dpr |
| Description |
Demonstrates how to accept multiple custom
drag and drop data formats, and display a pop-up menu at drop-time
to allow the user to choose which one to drop. |
| Download |
AcceptMany.zip  |
CustomTest
| Location |
Demos\Delphi\CustomFormats\CustomTest.dpr |
| Description |
Demonstrates dragging and dropping custom
formats using TDMTextSource and TDMTextTarget. You can encode your
information (either binary or text) as a string and pass it between
applications using a private format. This example demonstrates
passing a floating point (double) number between two applications
using a user-choosable clipboard format name. |
| Download |
CustomTest.zip  |
CustomTest2
| Location |
Demos\Delphi\CustomFormats\CustomTest2.dpr |
| Description |
Demonstrates dragging multiple data formats
simultaneously, using the CustomFormatData property of TDMTextSource.
Also demonstrates delayed rendering of custom data formats (i.e.,
the data is only made available if it is requested by the drop
target. In particular, shows how to drag files and shortcuts from
your application to Explorer. |
| Download |
CustomTest2.zip  |
CustomTest3
| Location |
Demos\Delphi\CustomFormats\CustomTest3.dpr |
| Description |
Demonstrates how a TDMTextTarget can accept
multiple data formats from the same drag source. |
| Download |
CustomTest3.zip  |
EMail
EMailTest
| Location |
Demos\Delphi\EMail\EMailTest.dpr |
| Description |
Demonstrates accepting drops of e-mail and
news messages from Outlook Express and Netscape (Messenger or
Collabra), Outlook (message and attachments), and Eudora Pro 4.x.
The messages are kept in a combination TListView/TMemo two-pane
window, similar to Outlook Express's and Netscape's own user
interfaces. In order to give reasonable text display in a simple
memo, HTML messages are massaged to remove tags. Also, demonstrates
some useful TStringList tricks for processing e-mail headers, as
well as extracting data from more unusual storage media like
IStorage and IStream. |
| Download |
EmailTest.zip  |
Feedback
Available
| Location |
Demos\Delphi\Feedback\Available.dpr |
| Description |
Demonstrates detecting the data formats
available when dragging over a TDMTextTarget (or TDMGraphicTarget)
in a simpler way than the lower-level technique in the FormatViewer
example. |
| Download |
Available.zip  |
CursorTest
| Location |
Demos\Delphi\Feedback\CursorTest.dpr |
| Description |
Demonstrates using custom drag cursors when
dragging content from a TDMTextSource. While one can simply use
cursors from resources, this example dynamically constructs drag
cursors to represent files dragged from a file list box, including
the correct OLE cursor and the file name and small icon. This
version works only under Windows NT, since Windows 95 will not
permit cursors to be bigger than the standard size (see the
CursorTest2 example for a more general solution). |
| Download |
CursorTest.zip  |
CursorTest2
| Location |
Demos\Delphi\Feedback\CursorTest2.dpr |
| Description |
Demonstrates using custom drag cursors when
dragging content from a TDMTextSource. While one can simply use
cursors from resources, this example dynamically constructs drag
cursors to represent files dragged from a file list box, including
the correct OLE cursor and the file name and small icon. This
version works on all Win32 platforms, and uses the imagelist
functions to manage the drag images (see the CursorTest example for
a simpler, NT-specific solution). |
| Download |
CursorTest2.zip  |
DropEffectTest
| Location |
Demos\Delphi\Feedback\DropEffectTest.dpr |
| Description |
Demonstrates displaying and manipulating drop
effects in a drop target, when content is dragged over it. By drop
effect, we mean "move", "copy" or
"link", and the accompanying cursor changes. Even if a
drop source is attempting to carry out a copy, e..g., the drop
target can force a move (or even ignore a given drop effect
completely). This example shows off the properties
AvailableDropEffects and OverrideDropEffects[] of TDMTextTarget and
TDMGraphicTarget. |
| Download |
DropEffectTest.zip  |
MouseButtonTest
| Location |
Demos\Delphi\Feedback\MouseButtonTest.dpr |
| Description |
Demonstrates dragging with mouse buttons
other than the left mouse button. You can drag different content (or
the same) depending on which of the mouse buttons initiates the
drag. It's also very simple to ensure than every mouse button does
the same drag operation, if desired. |
| Download |
MouseButtonTest.zip  |
FileContents
FileContentsTest
| Location |
Demos\Delphi\FileContents\FileContentsTest.dpr |
| Description |
Demonstrates dragging custom content into
Explorer. You can drag any binary data and have it saved into a file
name of your choosing in whatever folder of Explorer (including the
desktop) it's dropped on. |
| Download |
FileContentsTest.zip  |
FileContentsTest2
| Location |
Demos\Delphi\FileContents\FileContentsTest2.dpr |
| Description |
Demonstrates dragging content to be dropped
in Explorer as more than one file. It also shows how to delay-render
formats using the OnRenderCustomFormat event so you only have to
provide the actual data when requested, and how to drop content into
a named file in an Explorer folder. |
| Download |
FileContentsTest2.zip  |
FormatViewer
FormatViewer
| Location |
Demos\Delphi\FormatViewer\FormatViewer.dpr |
| Description |
Demonstrates the TDMTextTarget component's
access to the data object being dragged over it. Drag from any drag
source over this applications form to see a listing of all data
formats that can be supplied by the drag source (for a very
impressively long list, try dragging from MS Excel!) |
| Download |
FormatViewer.zip  |
General
DropMasterTest
| Location |
Demos\Delphi\General\DropMasterTest.dpr |
| Description |
The "kitchen sink" demo
application, designed to showcase almost all of the features of the
components. It demonstrates, using a tabbed dialog interface, drag
and drop of both text and graphics between applications, as well as
various user feedback techniques. There are examples here of
dragging text to or from TListBox, TListView, TTreeView and TMemo
controls, and dragging images to and from TImage components, as well
as run-time changes in the properties of the components based on
user input. If you don't have another drag and drop application
available (hint: everyone should have WordPad, which implements drag
and drop) such as Word, Excel, Internet Explorer, Netscape
Navigator, etc., you can run two instances of DropMasterTest and
drag and drop between them. |
| Download |
DropMasterTest.zip  |
HWndTest
| Location |
Demos\Delphi\General\HWndTest.dpr |
| Description |
Demonstrates using the DropMaster components
to add drag and drop behavior to a non-VCL window. We enumerate all
instances of Notepad, and allow the user to choose one of them as a
text drop target. |
| Download |
HWndTest.zip  |
WindowClassNameFinder
| Location |
Demos\Delphi\General\WindowClassNameFinder.dpr |
| Description |
Demonstrates UI feedback using a
TDMTextSource component, by displaying the window class name of
every window that you drag the mouse over. The windows don't have to
be VCL windows. |
| Download |
WindowClassNameFinder.zip  |
Graphics
DelayRenderDIBTest
| Location |
Demos\Delphi\Graphics\DelayRenderDIBTest.dpr |
| Description |
Demonstrates dragging device-independent
bitmaps from your program into another application. Uses delayed
rendering, i.e., the data is only actually placed in memory if and
when a drop occurs on an application that requests the data. |
| Download |
DelayRenderDIBTest.zip  |
DragJpegTest
| Location |
Demos\Delphi\Graphics\DragJPEGTest.dpr |
| Description |
Demonstrates dragging from a TImage that
contains a JPEG image to another application, using the
TDMGraphicSource component. |
| Download |
DragJPEGTest.zip  |
Grids
FileTest
| Location |
Demos\Delphi\Grids\FileTest.dpr |
| Description |
Demonstrates accepting drops of files from
Explorer and other file sources onto a TListView. All file
properties are displayed (icon, display name, file name, file size,
file type, file attributes) in the same format used by Explorer
itself. Both large and small icons are rendered using the system
image lists, and the TListView ViewStyle can be manipulated using a
set of radio buttons. You can drag shortcuts to one or more files
from the TListView onto the desktop (or Explorer) or any other drop
target that accepts shortcuts. A less sophisticated C++Builder
example is given below. |
| Download |
FileTest.zip  |
StringGridTest
| Location |
Demos\Delphi\Grids\StringGridTest.dpr |
| Description |
Demonstrates accepting text into a
TStringGrid, typically dragged from MS Excel. If the dropped cells
extend beyond the grid, enough new rows and columns are added to
accomodate the data. Also shows how to scroll the string grid and
give feedback for a better user interface. |
| Download |
StringGridTest.zip  |
Memos
RTFTest
| Location |
Demos\Delphi\Memos\RTFTest.dpr |
| Description |
Demonstrates accepting drops of Microsoft
Rich Text Format (RTF) or plain text in a simple memo. This is just
about the simplest possible demo you could write. There is a single
event handler for the OnDrop event of the TDMTextTarget, with one
one crucial line of code (which adds the dropped text to the TMemo). |
| Download |
RTFTest.zip  |
MemoTest
| Location |
Demos\Delphi\Memos\MemoTest.dpr |
| Description |
Demonstrates using the components' events to
give sophisticated user feedback. Specifically, this is a form
containing a simple TMemo which accepts text drops. During the drop
operation, the TMemo's caret follows the drag and the status bar
displays "Move to where?" or "Copy to where?"
depending on the drop effects, just as Microsoft Word does it. Also
shows how to handle character positioning in TMemo controls. |
| Download |
MemoTest.zip  |
OLE
EmbedTest
| Location |
Demos\Delphi\OLE\EmbedTest.dpr |
| Description |
Demonstrates accepting drops of OLE objects,
either linked or copied, onto a TOleContainer. For example, drop a
selection from Word onto this application and you get a
"live" or linked version of the document: change the
document in Word and it automatically changes in your linked
version, etc. Alternatively, drop with the "copy" option
selected, and you get a new copy of that object. Objects can be
edited in-place using the functionality of the TOleContainer. |
| Download |
EmbedTest.zip  |
Other
CompoundDoc
| Location |
Demos\Delphi\Other\CompoundDoc.dpr |
| Description |
Demonstrates loading an OLE structured
storage (compound) document using the functions in DMUtil and using
its streams and storages to populate a TTreeView. While this is not
directly related to drag and drop, the helper functions contain this
and other such useful functionality. |
| Download |
CompoundDoc.zip  |
Outlook
OutlookTest
| Location |
Demos\Delphi\Outlook\OutlookTest.dpr |
| Description |
Demonstrates accepting drops of e-mail
attachments, particularly from MS Outlook, which provides the data
in an unusual format (as bytes on an IStream interface, combined
with a file group descriptor to supply the names). |
| Download |
OutlookTest.zip  |
OutlookTest2
| Location |
Demos\Delphi\Outlook\OutlookTest2.dpr |
| Description |
Demonstrates dragging messages, appointments,
contacts, etc. from Microsoft Outlook into a TListView in your own
application. Uses Outlook's automation interface to re-open the
items when double-clicked. Additionally, we demonstrate building the
verb menu for the OLE object manually (as opposed to using
auto-activation) so we can trap for OLE exceptions.
Finally, we show how to save the OLE object contained in the
TOleContainer to a file, prompting with a TSaveDialog filled in with
the correct default extension, file filter and file type.
The example also contains a demonstration of the standard Delphi
"hack" to surface a protected event (OnDblClick, which
TOleContainer does not surface) without having to write a descendant
component. As it turns out, the bulk of this (still short) example
is devoted to the verb menu handling! |
| Download |
OutlookTest2.zip  |
RichEdits
RichEditTest
| Location |
Demos\Delphi\RichEdits\RichEditTest.dpr |
| Description |
Demonstrates accepting rich text format (RTF)
into a TRichEdit. Makes use of a utility function,
AddContentToRichEdit, in the DMUtil unit, which encapsulates the
EM_STREAMIN message. |
| Download |
RichEditTest.zip  |
RichEditTest2
| Location |
Demos\Delphi\Richedits\RichEditTest2.dpr |
| Description |
Demonstrates dragging to/from a plain text
rich edit control. Although TRichEdit handles drag and drop
natively, sometimes you need to override the drag and drop behavior
for other purposes. In this example, we handle the dragging and
dropping ourselves, so we can prevent drag and drop within the
TRichEdit. |
| Download |
RichEditTest2.zip  |
TreeViews
TreeViewTest
| Location |
Demos\Delphi\TreeViews\TreeViewTest.dpr |
| Description |
Demonstrates accepting drops only on specific
nodes of a TTreeView. The cursor correctly shows the drop/no-drop
indication depending on the node. |
| Download |
TreeViewTest.zip  |
URLs
DiscriminateShortcutsTest
| Location |
Demos\Delphi\URLs\DiscriminateShortcutsTest.dpr |
| Description |
Demonstrates how to discriminate, during a
drop, among a file, a URL, a URL contained in an Internet Explorer
shortcut, a shell shortcut, etc. This allows you to act on the drop
without special-case code. |
| Download |
DiscriminateShortcutsTest.zip  |
DragURLTest
| Location |
Demos\Delphi\URLs\DragUrlTest.dpr |
| Description |
Demonstrates dragging URLs to Netscape or
Internet Explorer from an application. Also shows how you can drag a
URL and drop a shortcut on the desktop (or any folder in Windows
Explorer). |
| Download |
DragUrlTest.zip  |
URLTest
| Location |
Demos\Delphi\URLs\URLTest.dpr |
| Description |
Demonstrates accepting URL drags from
Netscape or Internet Explorer into a TListView. |
| Download |
URLTest.zip  |
Word
uoSource
| Location |
Demos\Delphi\Word\uoSource.dpr |
| Description |
Demonstrates dragging content from an
application to be dropped as a live DDE link in MS Word. Works
around a bug whereby such links can disconnect prematurely under
Windows NT versions prior to SP4, by using a combination of
non-auto-updating links and OLE automation. Also shows how to drag
rich text format (RTF) snippets into MS Word, in this case the RTF
to code a specific macro.
Finally, demonstrates how a drag source can reject an incipient
drop on a given target by looking at the window class of the window
under the mouse in the TDMTextSource.OnBeforeDrop event. Normally a
drop source should be agnostic about the identity of the drop
target, except for the formats that the target should accept. This
is a good counter-example of a situation where the drop source needs
to know more. In particular, the technique allows us to drop the RTF
on MS Word, but to cancel attempts to drop the RTF on WordPad (which
understands RTF, but not this macro). |
| Download |
uoSource.zip  |
|
|

|
C++Builder Examples
General
CPPDragFileTest
| Location |
Demos\BCB\General\CPPDragFileTest.bpr |
| Description |
Demonstrates the use of TDMTextSource for
dragging files and shortcuts to the desktop or Explorer. You can
choose, using checkboxes, whether to allow any or all of the drop
effects copy, move and link (shortcut). This is effectively the
inverse of the CPPFileTest example. |
| Download |
n/a |
CPPTest
| Location |
Demos\BCB\General\CPPTest.bpr |
| Description |
Demonstrates the use of TDMTextTarget (for
text and URLs) and TDMGraphicTarget to accept dropped text and
graphic data. Accepts text and URLs in a TMemo, and images dragged
onto a TImage. |
| Download |
n/a |
Graphics
CPPDragImages
| Location |
Demos\BCB\Graphics\CPPDragImages.bpr |
| Description |
Demonstrates dragging and dropping graphical
content between images using the TDMGraphicSource and
TDMGraphicTarget components in C++Builder. |
| Download |
n/a |
Grids
CPPFileTest
| Location |
Demos\BCB\Grids\CPPFileTest.bpr |
| Description |
Demonstrates dragging files from Explorer or
another file drag source to a TListView. Displays the file path,
size, etc. A similar, more sopisticated Delphi version is the
FileTest example. |
| Download |
n/a |
Outlook
CPPOutlookTest
| Location |
Demos\BCB\Outlook\CPPOutlookTest.bpr |
| Description |
Demonstrates accepting drops of e-mail
attachments, particularly from MS Outlook, which provides the data
in an unusual format (as bytes on an IStream interface, combined
with a file group descriptor to supply the names). |
| Download |
n/a |
RichEdits
CPPRichEditDrag
| Location |
Demos\BCB\RichEdits\CPPRichEditDrag.bpr |
| Description |
Demonstrates dragging to and from a TRichEdit.
Test by dragging between this application and, e.g., MS-Word or
WordPad. |
| Download |
n/a |
TreeViews
CPPTreeViewTest
| Location |
Demos\BCB\TreeViews\CPPTreeViewTest.bpr |
| Description |
Demonstrates accepting drops only on specific
nodes of a TTreeView. The cursor correctly shows the drop/no-drop
indication depending on the node. |
| Download |
n/a |
URLs
CPPUrlTest
| Location |
Demos\BCB\URLs\CPPUrlTest.bpr |
| Description |
Demonstrates accepting URL drags from
Netscape or Internet Explorer into a TListView. Essentially
identical to the Delphi URLTest example. |
| Download |
n/a |
|
|
|
|