DragonDrop Help
Properties
Methods
Events
Types
Unit
DragonDrop
Description
DragonDrop is a fully functioning Component that easily allows you to Drag ITems to and
From Your Application
Currently its Capabilities include:
- Dragging Files, Text, Rich Text, Links, Netscape Text, Word Documents, Word Images,
Internet Explorer, MetaFiles and Bitmaps To and From your application
with other applications. You can also drag from your application to your application.
- The component can be used with many other applications as well. Only your imagination
can limit you now.
Properties
Methods
Types
Properties
Property:
DropWindow
Applies to: DragonDrop
property type: TWinControl
Description
You choose the window that will accept the drag from the list of windowed
controls that are presented to you in the list.
You can also set the DropWindow pragmatically:
Methods
Method:
AboutBox
Applies to: DragonDrop
Declaration: procedure AboutBox;
Description
Displays a copyright box, with the location of the polarware web site and an
email address. Both the URL and EMAIL Addresses are click able.
Method:
BeginDragFile
Applies to: DragonDrop
Declaration: function BeginDragFile(FileNames: TStrings): LongInt;
Results:
DRAGDROP_S_DROP: Indicates the OLE drag and drop operation was successful.
DRAGDROP_S_CANCEL: Indicates the OLE drag and drop operation was canceled.
Description
iNames must be a fully qualified list of FileNames; meaning each item is a file with
its full path. ie. c:\program files\delphi 3\bin\delphi.exe
procedure TfrmMain.FileListBoxMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
S: TStrings;
I: Integer;
begin
if ssLeft in Shift then begin
S := tStringList.Create;
with FileListBox do
try
// Add the path to each file
for I := 0 to Items.Count-1 do
if Selected[i] then
S.Add(Directory + '\' + Items[i]);
fddComp.BeginDragFile(S);
finally
S.Free;
end; // R.P.B.
end; // if
end; // TfrmMain.FileListBoxMouseMove
Method:
BeginDragUnicode
Applies to: DragonDrop
Declaration: function BeginDragUnicode(Lines: TStrings): LongInt;
Results:
DRAGDROP_S_DROP: Indicates the OLE drag and drop operation was successful.
DRAGDROP_S_CANCEL: Indicates the OLE drag and drop operation was canceled.
Description
Lines is a String List of text that you wish to be dragged to some application,
that will accept them in Unicode(even yourself).
Method:
BeginDragText
Applies to: DragonDrop
Declaration: function BeginDragText(Lines: TStrings): LongInt;
Results:
DRAGDROP_S_DROP: Indicates the OLE drag and drop operation was successful.
DRAGDROP_S_CANCEL: Indicates the OLE drag and drop operation was canceled.
Description
Lines is a String List of text that you wish to be dragged to some application,
that will accept them in Unicode(even yourself). Netscape is a good example of this.
Method:
BeginDragRichText
Applies to: DragonDrop
Declaration: function BeginDragRichText(Lines: TStrings): LongInt;
Results:
DRAGDROP_S_DROP: Indicates the OLE drag and drop operation was successful.
DRAGDROP_S_CANCEL: Indicates the OLE drag and drop operation was canceled.
Description
Lines is a String List of Rich Text that you wish to be dragged to another application,
Word would be a good example of this.
some application,
that will accept them in Unicode(even yourself).
Method:
BeginDragEnhMetaFile
Applies to: DragonDrop
Declaration: function BeginDragEnhMetaFile(Graphic: TGraphic): LongInt;
Results:
DRAGDROP_S_DROP: Indicates the OLE drag and drop operation was successful.
DRAGDROP_S_CANCEL: Indicates the OLE drag and drop operation was canceled.
Description
The Graphic can be any of the desendant Graphic objects such as TBitmap or TMetaFile.
They will be converted into a Enhanced Meta file and then sent to the application that
the user drags to.
Method:
BeginDragBitmap
Applies to: DragonDrop
Declaration: function BeginDragBitmap(Graphic: TGraphic): LongInt;
Results:
DRAGDROP_S_DROP: Indicates the OLE drag and drop operation was successful.
DRAGDROP_S_CANCEL: Indicates the OLE drag and drop operation was canceled.
Description
The Graphic can be any of the desendant Graphic objects such as TBitmap or TMetaFile.
They will be converted into a TBitmap and then sent to the application that the user
drags to.
Method:
BeginDrag
Applies to: DragonDrop
Declaration: function BeginDrag(SourceType: TSourceTypes; Source: TDropObj): LongInt;
Results:
DRAGDROP_S_DROP: Indicates the OLE drag and drop operation was successful.
DRAGDROP_S_CANCEL: Indicates the OLE drag and drop operation was canceled.
Description
All the other BeginDragXXXXXXXXX Types are wrappers for this method. They do all
the special work that is needed to send ONE tpe of information via Drag and Drop
to another application. There will be many times where you will want to do more than one format
say an image and its FileName.
To use this function here is a couple of examples.
function TForm1.BeginDragFile(Graphic: TGraphic; FileName: TStrings): LongInt;
Var
SourceType: TSourceType;
Source: TDropObj;
MF: TMetaFile;
begin
MF := TMetaFile.Create;
try
with TMetafileCanvas.Create(MF, 0) do
try
Draw(0, 0, Graphic);
Finally
Free;
End; // R.P.B.
Source := TDropObj.Create;
Source.Items[stFileNames] := FileName;
Source.Items[stEnhMetaFile] := MF;
Result := BeginDrag([stFileNames, stEnhMetaFile], Source);
end; // TForm1.BeginDragFile
Events
Event:
OnDragEnter
Applies to: DragonDrop
Declaration: procedure OnEnter(Sender: TObject; SourceType:
TSourceTypes);
Description
Only SourceType: tsFileNames is currently supported.
As soon as a drag enters the windowed control specified in the
DropWindow, this event will fire.
Event:
OnDragOver
Applies to: DragonDrop
Declaration: procedure DragOverProc(Sender: TObject; SourceType: TSourceTypes;
X, Y: Integer; var KeyState: TShiftState;
var Accept: Boolean);
Description
When a user drags something over a chosen control, this control receives an OnDragOver event, at
which time it must indicate whether it can accept the item if the user drops it there. Delphi
changes the drag cursor to indicate whether the control can accept the dragged item.
To accept items dragged over a control, Attach an event handler to this OnDragOver event.
The drag-over event has a variable parameter called Accept that the event handler can set to
True if it will accept the item. Setting Accept to True specifies that if the user releases
the mouse button at that point, dropping the dragged item, the application can then send a
drag-drop event to the same control. If Accept is False, the application won't drop the item
on that control. This means that a control should never have to handle a drag-drop event for
an item it doesn't know how to handle.
The drag-over event includes several parameters, including the source of the dragging and the
current location of the mouse cursor. The event handler can use those parameters to determine
whether to accept the drop. Most often, a control accepts or rejects a dragged item based on
the type of the sender, but it can also accept items only from specific instances.
Only SourceType: tsFileNames is currently supported.
As soon as a drag enters the windowed control specified in the
DropWindow, this event will fire.
Example
In the following example, we only accept if the type is of tsFileNames
procedure TFMForm.OutLineDragOver(Sender: TObject; SourceType: TSourceTypes; X, Y: Integer; var KeyState: TShiftState; var Accept: Boolean);
begin
if tsFileNames in SourceType then
Accept := True;
else
Accept := False;
end; // TFMForm.OutLineDragOver
Event:
OnDragDrop
Applies to: DragonDrop
Declaration: procedure DragDrop(Sender, Source: TObject; SourceType: TSourceTypes; X, Y: Integer;
KeyState: TShiftState);
Description
Only SourceType: tsFileNames is currently supported. As soon as a drag enters
the windowed control specified in the
DropWindow. This event will fire.
Once the control indicates that it will accept a dragged item, it should then also define some
way to handle the item should it be dropped. If a user sees the mouse cursor change to indicate
that a control will accept the item being dragged, it is reasonable for the user to then expect
that dropping the item there will accomplish some task.
To handle dropped items, Attach an event handler to the OnDragDrop event of this control to accept
the dropped item.
Like the drag-over event, the drag-drop event indicates the source of the dragged item and the
coordinates of the mouse cursor over the accepting control. These parameters enable the drag-drop
handler to get any needed information from the source of the drag and determine how to handle it.
Example
For example, a directory outline accepting items dragged from a file list box can move the file from its current location to the directory dropped on:
procedure TFMForm.MemoDragDrop(Sender, Source: TObject; SourceType: TSourceTypes; X, Y: Integer; KeyState: TShiftState);
begin
Memo1.Lines.Assign(TStrings(Source));
end; // TFMForm.MemoDragDrop
Event:
OnDragBeforeDrop
Applies to: DragonDrop
Declaration: procedure OnDragBeforeDrop(Sender: TObject);
Description
When the user releases the mouse over a window that accepts the Drop,
this event is fired to allow the user to do any special processing, before the
data is passed to the calling application.
Note: this event will be extended as users make requests to better
make use of DragonDrop in their applications.
Event:
OnDragLeave
Applies to: DragonDrop
Declaration: procedure OnLeave(Sender: TObject);
Description
As the drag is leaving the windowed control specified in the
DropWindow. This event will fire.
Types
Type:
TSourceTypes
Declaration: TSourceType = (stFileNames,
stUnicode, stText, stRichText,
stBitMap, stEnhMetaFile);