Sample Application: uoddtest.dpr

This is a comprehensive demonstration of the drag and drop components. It contains 4 TUOTextSources, 4 TUOGraphicSources, 2 TUOTextTargets and 1 TUOGraphicTarget. The source is heavily commented as this is mainly intended to be a tutorial application.

Project source
Form source (Pascal)
Form source (DFM)

Design-time form image
Project source: uoddtest.dpr

Program UODDTest;

{Main program file for test application for UnitOOPS OLE Drag and Drop Components.

Last modified:  07/04/98}

uses
  Forms,
  fmuoddtest in 'fmuoddtest.pas' {Form1};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
Back to top
Form source: fmUODDTest.pas

unit fmuoddtest;

{Test form for drag-and-drop between applications using the UnitOOPS OLE Drag
 and Drop Components.

 Demonstrates various techniques in the use of TUOTextSource, TUOTextTarget,
 TUOGraphicSource, TUOGraphicTarget.

 The main point here - see how little code is needed.  Most of the code here
 was written by Delphi!  And the portion that was manually coded is mainly
 for user-interface purposes.

 Last modified: 09/29/99}

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  uoole, StdCtrls, ComCtrls, Buttons, Grids, ExtCtrls;

type
  TForm1 = class(TForm)
    pnlButtons: TPanel;
    Panel1: TPanel;
    btnClose: TButton;
    Panel2: TPanel;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    UOTextSource1: TUOTextSource;
    UOTextTarget1: TUOTextTarget;
    ListBox1: TListBox;
    StaticText1: TStaticText;
    UOTextTarget2: TUOTextTarget;
    UOTextSource2: TUOTextSource;
    UOTextSource3: TUOTextSource;
    Memo1: TMemo;
    TabSheet3: TTabSheet;
    Label1: TLabel;
    Label2: TLabel;
    ListBox2: TListBox;
    Label3: TLabel;
    CheckBox2: TCheckBox;
    Label4: TLabel;
    CheckBox1: TCheckBox;
    Label5: TLabel;
    Label6: TLabel;
    ListBox3: TListBox;
    CheckBox3: TCheckBox;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    TabSheet4: TTabSheet;
    TreeView1: TTreeView;
    Label10: TLabel;
    ListView1: TListView;
    Label11: TLabel;
    Label12: TLabel;
    UOTextSource4: TUOTextSource;
    Label13: TLabel;
    Label14: TLabel;
    TabSheet5: TTabSheet;
    Panel3: TPanel;
    GroupBox1: TGroupBox;
    Panel4: TPanel;
    Label19: TLabel;
    Label18: TLabel;
    Label21: TLabel;
    Label22: TLabel;
    Label23: TLabel;
    Label20: TLabel;
    CheckBox4: TCheckBox;
    CheckBox5: TCheckBox;
    RadioGroup1: TRadioGroup;
    Label24: TLabel;
    TabSheet6: TTabSheet;
    UOGraphicTarget1: TUOGraphicTarget;
    Panel5: TPanel;
    Label25: TLabel;
    TabSheet7: TTabSheet;
    Label26: TLabel;
    Label27: TLabel;
    Image2: TImage;
    UOGraphicSource1: TUOGraphicSource;
    Label28: TLabel;
    Label29: TLabel;
    Image3: TImage;
    Label30: TLabel;
    CheckBox6: TCheckBox;
    Label31: TLabel;
    UOGraphicSource2: TUOGraphicSource;
    RadioGroup2: TRadioGroup;
    CheckBox7: TCheckBox;
    UOGraphicSource3: TUOGraphicSource;
    CheckBox8: TCheckBox;
    ScrollBox1: TScrollBox;
    Image1: TImage;
    Panel6: TPanel;
    UOGraphicSource4: TUOGraphicSource;
    CheckBox9: TCheckBox;
    CheckBox10: TCheckBox;
    CheckBox11: TCheckBox;
    procedure ListBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure ListBox2StartDrag(Sender: TObject;
      var DragObject: TDragObject);
    procedure ListView1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure UOTextTarget1Drop(Sender: TObject; Acceptor: TWinControl;
      const dropText: String; X, Y: integer);
    procedure btnCloseClick(Sender: TObject);
    procedure UOTextSource2BeforeDrop(Sender: TObject; Donor: TComponent;
      var dropText: String; var cancelDrop: Boolean);
    procedure UOTextSource2AfterDrop(Sender: TObject; Donor: TComponent;
      droppedOK: Boolean);
    procedure UOTextTarget2Drop(Sender: TObject; Acceptor: TWinControl;
      const dropText: String; X, Y: integer);
    procedure TreeView1StartDrag(Sender: TObject;
      var DragObject: TDragObject);
    procedure ListView1StartDrag(Sender: TObject;
      var DragObject: TDragObject);
    procedure UOTextSource4AfterDrop(Sender: TObject; Donor: TComponent;
      droppedOK: Boolean);
    procedure CheckBox4Click(Sender: TObject);
    procedure UOTextSource3AfterDrop(Sender: TObject; Donor: TComponent;
      droppedOK: Boolean);
    procedure UOTextSource3BeforeDrop(Sender: TObject; Donor: TComponent;
      var dropText: String; var cancelDrop: Boolean);
    procedure RadioGroup1Click(Sender: TObject);
    procedure UOTextTarget1DragEnter(Sender: TObject;
      effect: TDropEffect; X, Y: Integer);
    procedure UOTextTarget1DragLeave(Sender: TObject);
    procedure UOTextTarget1DragOver(Sender: TObject; effect: TDropEffect;
      X, Y: Integer);
    procedure FormCreate(Sender: TObject);
    procedure UOGraphicTarget1Drop(Sender: TObject; Acceptor: TWinControl;
      thePicture: TPicture; X, Y: Integer);
    procedure CheckBox6Click(Sender: TObject);
    procedure Image2StartDrag(Sender: TObject;
      var DragObject: TDragObject);
    procedure Image3StartDrag(Sender: TObject;
      var DragObject: TDragObject);
    procedure RadioGroup2Click(Sender: TObject);
    procedure CheckBox7Click(Sender: TObject);
    procedure Image1StartDrag(Sender: TObject;
      var DragObject: TDragObject);
    procedure Panel6StartDrag(Sender: TObject;
      var DragObject: TDragObject);
    procedure CheckBox9Click(Sender: TObject);
    procedure CheckBox10Click(Sender: TObject);
    procedure CheckBox11Click(Sender: TObject);
  private
    { Private declarations }
    saveAcceptGraphicFormats: TDropGraphicFormats;

    procedure updateAcceptGraphicFormats;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses
  TypInfo;

procedure TForm1.ListBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
// Drag detection for ListBox1.  Style #1 - mouse-move with left button down.
// Style #2 (see ListBox2StartDrag) is preferred.
begin
  if (ssLeft in Shift) then
    UOTextSource1.Execute;
end;

procedure TForm1.ListBox2StartDrag(Sender: TObject;
  var DragObject: TDragObject);
// Drag detection for ListBox2.  Style #2 - start drag with DragMode = dmAutomatic,
// followed by abort..
begin
  UOTextSource2.Execute;

  Abort; // to kill the Delphi drag/drop operation
end;

procedure TForm1.ListView1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if ssLeft in Shift then
    UOTextSource1.execute;
end;

procedure TForm1.UOTextTarget1Drop(Sender: TObject; Acceptor: TWinControl;
  const dropText: String; X, Y: integer);
// Handle drops on memo1.  Notify the user whether files or just non-file text
// has been dropped.

begin
  label24.caption := Format('%s: (%d,%d)', ['Drop', X, Y]);

  if ((Sender as TUOTextTarget).DroppedTextFormat = dtfFiles) then
    label24.caption := label24.caption + ' [files]'
  else
    label24.caption := label24.caption + ' [text]';

  // If this is a URL, the actual URL address is in dropText
  // (also in droppedLines[0] and Text).  The title is in URLTitle.
  if ((Sender as TUOTextTarget).DroppedTextFormat = dtfURL) then
    label24.caption := label24.caption
      + Format(' [URL, title=%s]', [(Sender as TUOTextTarget).URLTitle]);

  // The only REQUIRED part of this handler.  Do something with the text
  // that was just dropped.  If this is missing, the drop won't do anything.
  // You have to decide what you want to do with the text you get!
  memo1.lines.add(dropText);
  // The following line is equivalent to the preceding line.
  // memo1.lines.add((Sender as TUOTextTarget).Text);

end;

procedure TForm1.btnCloseClick(Sender: TObject);
// Close down
begin
  Application.Terminate;
end;

procedure TForm1.UOTextSource2BeforeDrop(Sender: TObject;
  Donor: TComponent; var dropText: String; var cancelDrop: Boolean);
// Called before the drop of text from UOTextSource2.  Allow the
// user to cancel.  You can modify dropText here if you want.
//
// This handler is shared by UOTextSource1 and UOTextSource2.  The particular
// one in question is identified by looking at Sender.
var
  aString: string;
  showConfirmation: boolean;
begin
  showConfirmation := ((Sender = UOTextSource1) and (CheckBox1.Checked))
    or ((Sender = UOTextSource2) and (CheckBox2.Checked));
  if showConfirmation then
  begin
    if (deMove = (Sender as TUOTextSource).ReturnedEffect) then
      aString := 'Do you really want to move the string "%s"?'
    else
      aString := 'Do you really want to copy the string "%s"?';

    aString := Format(aString, [dropText]);

    cancelDrop := (MessageDlg(aString, mtConfirmation, [mbYes, mbNo], 0) = mrNo);
  end;
end;

procedure TForm1.UOTextSource2AfterDrop(Sender: TObject; Donor: TComponent;
  droppedOK: Boolean);
var
  j: integer;
begin
  // A drop has been done from UOTextSource2.  If the drop was a move, we
  // have to remove the text from ListBox2.  You have to make sure that
  // droppedOK is true;  if you end the drag while the "no drag" cursor is
  // showing, this event will still fire, but with droppedOK = false.
  //
  // In this handler, the expressions (Sender as TUOTextSource).DonorComponent,
  // Donor, and ListBox2 all refer to the same thing.

  if droppedOK then
  begin
    if (deMove = (Sender as TUOTextSource).ReturnedEffect) then
    begin
      // It's a move.  Delete from the top down to avoid messing
      // up the Selected[] property.
      for j := ListBox2.items.count downTo 1 do    // Iterate
      begin
        if ListBox2.Selected[j-1] then
          ListBox2.items.delete(j-1);
      end;    // for
    end;

  end;
end;

procedure TForm1.UOTextTarget2Drop(Sender: TObject; Acceptor: TWinControl;
  const dropText: String; X, Y: integer);
// Handle drops on ListBox3
//var
//  j: integer;
///  aSL: TStringList;
begin
  // Bring the form to the top, so that the message dialog won't accidentally
  // be hidden.
  SetForegroundWindow(Handle);

  if CheckBox3.Checked and
    (MessageDlg('Do you want to clear the list before dropping?', mtConfirmation,
      [mbYes, mbNo], 0) = mrYes) then
    ListBox3.Items.Clear;

  // Show a sign that files were dropped (rather than text)
  Label7.visible := ((Sender as TUOTextTarget).DroppedTextFormat = dtfFiles);

  // Handle the drop.  Show the coordinates, just for fun.
  ListBox3.Items.Add(Format('      Drop at client pos (%d,%d):', [X, Y]));
  ListBox3.Items.AddStrings((Sender as TUOTextTarget).DroppedLines);

  // The following is equivalent to the preceding line, i.e., DroppedLines
  // and dropText contain the same information.
  //aSL := TStringList.create;
  //try
  //  // Get the dropped text into dropText
  //  aSL.text := dropText;
  //  for j := 1 to aSL.count do    // Iterate
  //  begin
  //    ListBox3.Items.Add(aSL[j-1]);
  //  end;    // for
  //finally
  //  aSL.free;
  //end;

end;

procedure TForm1.TreeView1StartDrag(Sender: TObject;
  var DragObject: TDragObject);
begin
  // For the explanation of the following line, see UOTextSource3BeforeDrop
  UOTextSource3.DonorComponent := TreeView1;
  UOTextSource3.Execute;

  Abort; // to kill the Delphi drag/drop operation
end;

procedure TForm1.ListView1StartDrag(Sender: TObject;
  var DragObject: TDragObject);
begin
  UOTextSource4.Execute;

  Abort; // to kill the Delphi drag/drop operation
end;

procedure TForm1.UOTextSource4AfterDrop(Sender: TObject; Donor: TComponent;
  droppedOK: Boolean);
var
  aLi, bLi: TListItem;
begin
  // A drop has been done from UOTextSource4.  If the drop was a move, we
  // have to remove the selections from ListView1.  You have to make sure that
  // droppedOK is true;  if you end the drag while the "no drag" cursor is
  // showing, this event will still fire, but with droppedOK = false.
  // This allows you to something on such an operation.

  if droppedOK then
  begin
    if (deMove = (Sender as TUOTextSource).ReturnedEffect) then
    begin
      // It's a move.  Delete the selected ones.
      // Loop over the selected members of the TListView items
      with (Donor as TListView) do
      begin
        Items.BeginUpdate; // Efficiency

        aLi := Selected;
        while assigned(GetNextItem(aLi, sdAll, [isSelected])) do
        begin
          bLi := aLi;
          aLi := GetNextItem(aLi, sdAll, [isSelected]);
          // We know it's assigned - look at the while statement above...
          bLi.delete;
        end;    // while
        // There's one left - delete it
        aLi.delete;

        Items.EndUpdate; // Efficiency
      end;    // with
    end;
  end;

end;

procedure TForm1.CheckBox4Click(Sender: TObject);
begin
  ListView1.Multiselect := CheckBox4.checked;
end;

procedure TForm1.UOTextSource3AfterDrop(Sender: TObject; Donor: TComponent;
  droppedOK: Boolean);
begin
  // A drop has been done from UOTextSource3.  If the drop was a move, we
  // have to remove the selections from TreeView1.  You have to make sure that
  // droppedOK is true;  if you end the drag while the "no drag" cursor is
  // showing, this event will still fire, but with droppedOK = false.
  //
  // We'll explicitly refer to TreeView1 rather than (Donor as TreeView)
  // for reasons explained in UOTextSource3BeforeDrop.

  if droppedOK then
  begin
    if (deMove = (Sender as TUOTextSource).ReturnedEffect) then
    begin
      // It's a move.  Delete the selected ones
      with TreeView1 do
      begin
        if assigned(Selected) then
          Selected.Delete;
      end;    // with
    end;
  end;

end;

procedure TForm1.UOTextSource3BeforeDrop(Sender: TObject;
  Donor: TComponent; var dropText: String; var cancelDrop: Boolean);
// We're about to get a drop from the tree view.  If the checkbox is
// checked, we're going to pass the complete path to the selected node
// as opposed to the node's title alone.  Otherwise, we do nothing.
//
// NB - modifying the dropText when we have a DonorComponent will disconnect
// the DonorComponent.  For this reason, we reassign it explicily just before
// the Execute call in TreeView1StartDrag
const
  separator = '\'; // Separate nodes with this
var
  aTn: TTreeNode;
begin
  // Bale out if the checkbox is not checked.
  if not CheckBox5.checked then exit;

  with (Donor as TTreeView) do
  begin

    aTn := Selected;

    // Now, build it from the node toward the root
    dropText := aTn.Text;
    while (aTn.Parent <> nil) do
    begin
      dropText := aTn.Parent.Text + separator + dropText;
      aTn := aTn.Parent;
    end;    // while
  end;    // with

  // Put a header on it
  dropText := separator + separator + dropText;

end;

procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
  ListView1.ViewStyle := TViewStyle(RadioGroup1.ItemIndex);
end;

procedure TForm1.UOTextTarget1DragEnter(Sender: TObject;
  effect: TDropEffect; X, Y: Integer);
// Handle drag enter for UOTextTarget1
begin
  label24.caption := Format('%s: (%d,%d) %s', ['Enter', X, Y, stringFromDropEffects([effect])]);
end;

procedure TForm1.UOTextTarget1DragLeave(Sender: TObject);
// Handle drag leave for UOTextTarget1
begin
  label24.caption := 'Leave';
end;

procedure TForm1.UOTextTarget1DragOver(Sender: TObject;
  effect: TDropEffect; X, Y: Integer);
// Handle drag over for UOTextTarget1
begin
  label24.caption := Format('%s: (%d,%d) %s', ['Over', X, Y, stringFromDropEffects([effect])]);
  // "effect" in the preceding could be replaced by
  // "(Sender as TUOTextTarget).DropEffect"
end;

procedure TForm1.FormCreate(Sender: TObject);
// Set up at form creation time
var
  i, j: integer;
begin
  // When the form loads, make sure the page showing is the
  // last one (to show the Help/About text)
  with PageControl1 do
  begin
    ActivePage := Pages[PageCount-1];
  end;    // with

  // Save the design-time state of the acceptable graphic formats
  // This is only for UI convenience later in implementing "Preferred only"
  saveAcceptGraphicFormats := UOGraphicTarget1.AcceptGraphicFormats;

  // Set various controls in the correct state
  RadioGroup2.itemIndex := integer(UOGraphicTarget1.PreferredFormat);

  with UOGraphicTarget1 do
  begin
    // Is the preferred format the only one?
    CheckBox7.Checked := [PreferredFormat] = AcceptGraphicFormats;
  end;    // with
  
  CheckBox9.checked := UOTextTarget1.AcceptIEHTML;
  CheckBox10.Checked := UOTextTarget2.AcceptFiles;
  CheckBox11.Checked := UOTextTarget1.AcceptRichText;
  // Preceding 2 lines are equivalent to the (more cumbersome)
  // CheckBox9.checked := (atIEHTML in UOTextTarget1.AcceptTextFormats);
  // CheckBox10.checked := (atFiles in UOTextTarget2.AcceptTextFormats);

  // Opening a D4 project in D3 messes up the TListView contents, so we
  // set some listview contents manually to avoid this.  This is only to allow
  // us to use the same example .DFM in both D3 and D4, without worrying about
  // losing the contents by opening in D4.
  with ListView1 do
  begin
    // Add 4 items
    for i := 1 to 4 do
    begin
      with Items.add do
      begin
        caption := Format('Item %d,1', [i]);;
        with subItems do
        begin
          for j := 2 to 4 do
          begin
            add(Format('Item %d,%d', [i, j]));
          end;
        end;
      end;
    end;
    // Try one with blanks
    with Items.add do
    begin
      caption := 'One more';
      with subItems do
      begin
        add('');
        add('testing');
      end;
    end;
  end;
end;

procedure TForm1.UOGraphicTarget1Drop(Sender: TObject;
  Acceptor: TWinControl; thePicture: TPicture; X, Y: Integer);
var
  aString: string;
begin
  if assigned(thePicture) then
  begin
    // Give the picture to the TImage.  The following 2 lines are equivalent.
    // image1.picture := (Sender as TUOGraphicTarget).Picture;
    image1.picture := thePicture;

    // Optionally stretch depending on checkbox.
    image1.stretch := CheckBox6.checked;

    // Show in the label what kind of object got dropped
    //aString := Image1.picture.graphic.ClassName;
    //Delete(aString, 1, 1);  // Drop the leading "T"
    // Following is an alternative for the preceding 2 lines
    case (Sender as TUOGraphicTarget).DroppedGraphicFormat of
      dgfBitmap: aString := 'Bitmap';
      dgfMetafile: aString := 'Metafile';
    else
      aString := '???'; // Should never happen!
    end;
    label31.caption := 'Dropped a '+ aString;
  end;
end;

procedure TForm1.CheckBox6Click(Sender: TObject);
begin
  with Image1 do
  begin
    // If the image is empty, don't do anything
    if not ((Picture.width=0) and (Picture.height=0)) then
    begin
      Stretch := CheckBox6.checked; // Are we stretching?
      // Image1.AutoSize and ScrollBox1.AutoScroll need to match
      AutoSize := not Stretch;
      ScrollBox1.AutoScroll := not Stretch;

      if Stretch then
        // Stretching, so reset the image to match the scrollbox bounds
        SetBounds(ScrollBox1.left, ScrollBox1.top, ScrollBox1.width, ScrollBox1.height);
    end;
  end;
end;

procedure TForm1.Image2StartDrag(Sender: TObject;
  var DragObject: TDragObject);
begin
  UOGraphicSource1.execute;

  abort;
end;

procedure TForm1.Image3StartDrag(Sender: TObject;
  var DragObject: TDragObject);
begin
  UOGraphicSource2.execute;

  abort;
end;

procedure TForm1.RadioGroup2Click(Sender: TObject);
begin
  // Choose a new preferred format
  UOGraphicTarget1.PreferredFormat := TDropGraphicFormat(RadioGroup2.itemIndex);

  // And make sure the acceptible formats are updated as a result
  updateAcceptGraphicFormats;
end;

procedure TForm1.updateAcceptGraphicFormats;
// After a change in the preferred format, or in whether the preferred format
// alone is acceptable, update the acceptable formats.
begin
  with UOGraphicTarget1 do
  begin
    if CheckBox7.Checked then
      // Preferred only - i.e., use the preferred one if it intersects with the
      // design-time acceptable graphic formats (set intersection)
      AcceptGraphicFormats := [PreferredFormat]*saveAcceptGraphicFormats
    else
      // Not preferred only - take the design-time defaults
      AcceptGraphicFormats := saveAcceptGraphicFormats;
  end;    // with
end;

procedure TForm1.CheckBox7Click(Sender: TObject);
begin
  updateAcceptGraphicFormats;
end;

procedure TForm1.Image1StartDrag(Sender: TObject;
  var DragObject: TDragObject);
begin
  // If we're allowed, do a drag from this image
  if CheckBox8.checked then
  begin
    UOGraphicSource3.execute;

  end;
  // Either way, abort the native Delphi drag
  Abort;
end;

procedure TForm1.Panel6StartDrag(Sender: TObject;
  var DragObject: TDragObject);
begin
  // No DonorImage this time.  Just get the image of the form's client area
  // into the Picture property, and execute the graphic source.
  // See how easy this is?
  UOGraphicSource4.Picture.Bitmap := GetFormImage;
  UOGraphicSource4.execute;

  Abort;
end;

procedure TForm1.CheckBox9Click(Sender: TObject);
// Handle checkbox click for accepting IEHTML format
begin
  UOTextTarget1.AcceptIEHTML := CheckBox9.Checked;

  // Preceding is equivalent to the (more cumbersome)
  // if CheckBox9.Checked then
  //   UOTextTarget1.AcceptTextFormats := UOTextTarget1.AcceptTextFormats + [atIEHTML]
  // else
  //   UOTextTarget1.AcceptTextFormats := UOTextTarget1.AcceptTextFormats - [atIEHTML];
end;

procedure TForm1.CheckBox10Click(Sender: TObject);
// Demonstrate dynamic change in accept formats.
begin
  UOTextTarget2.AcceptFiles := CheckBox10.Checked;

  // Preceding is equivalent to manipulating UOTextTarget2.AcceptTextFormats
  // (see CheckBox9Click method immediately above)
  // and is one of several Accept* public properties on the target
  // components provided for convenience.
end;

procedure TForm1.CheckBox11Click(Sender: TObject);
// Handle checkbox click for accepting RTF
begin
  UOTextTarget1.AcceptRichText := CheckBox11.Checked;
end;

end.
Back to top
Form source: fmUODDTest.dfm

object Form1: TForm1
  Left = 176
  Top = 180
  BorderStyle = bsDialog
  Caption = 'Test application for UnitOOPS Software Drag and Drop Components'
  ClientHeight = 332
  ClientWidth = 562
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object pnlButtons: TPanel
    Left = 0
    Top = 291
    Width = 562
    Height = 41
    Align = alBottom
    BevelOuter = bvNone
    BorderWidth = 3
    TabOrder = 0
    object Label14: TLabel
      Left = 3
      Top = 3
      Width = 461
      Height = 35
      Align = alClient
      AutoSize = False
      Caption = 
        'If you have no other drag and drop applications available for te' +
        'sting, run two instances of this program and drag and drop betwe' +
        'en them.'
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clActiveCaption
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ParentColor = False
      ParentFont = False
      WordWrap = True
    end
    object Panel1: TPanel
      Left = 464
      Top = 3
      Width = 95
      Height = 35
      Align = alRight
      BevelOuter = bvNone
      TabOrder = 0
      object btnClose: TButton
        Left = 12
        Top = 6
        Width = 75
        Height = 25
        Caption = 'Close'
        TabOrder = 0
        OnClick = btnCloseClick
      end
    end
  end
  object Panel2: TPanel
    Left = 0
    Top = 0
    Width = 562
    Height = 291
    Align = alClient
    BevelOuter = bvNone
    BorderWidth = 3
    TabOrder = 1
    object PageControl1: TPageControl
      Left = 3
      Top = 3
      Width = 556
      Height = 285
      ActivePage = TabSheet2
      Align = alClient
      TabOrder = 0
      object TabSheet1: TTabSheet
        Caption = 'Drag demo &1'
        object Label1: TLabel
          Left = 16
          Top = 16
          Width = 104
          Height = 13
          Caption = 'Single-selection, Copy'
        end
        object Label4: TLabel
          Left = 160
          Top = 32
          Width = 289
          Height = 57
          AutoSize = False
          Caption = 
            'Drag a selection from this list box to any valid drop target, e.' +
            'g., Word, Excel, or a TUOTextTarget-enabled window.   Only Copy ' +
            'is supported by this text source.'
          WordWrap = True
        end
        object ListBox1: TListBox
          Left = 16
          Top = 32
          Width = 121
          Height = 193
          ItemHeight = 13
          Items.Strings = (
            'Apples'
            'Bananas'
            'Peaches'
            'Pears'
            'Nectarines'
            'Tomatoes'
            'Oranges'
            'Plums')
          TabOrder = 0
          OnMouseMove = ListBox1MouseMove
        end
        object StaticText1: TStaticText
          Left = 24
          Top = 280
          Width = 58
          Height = 17
          Caption = 'StaticText1'
          TabOrder = 1
        end
        object CheckBox1: TCheckBox
          Left = 160
          Top = 96
          Width = 265
          Height = 17
          Caption = 'Display confirmation message before drop'
          State = cbChecked
          TabOrder = 2
        end
      end
      object TabSheet3: TTabSheet
        Caption = 'Drag demo &2'
        object Label2: TLabel
          Left = 16
          Top = 16
          Width = 153
          Height = 13
          Caption = 'Multiple-selection, Copy or Move'
        end
        object Label3: TLabel
          Left = 160
          Top = 32
          Width = 289
          Height = 57
          AutoSize = False
          Caption = 
            'Drag multiple selections from this list box to any valid drop ta' +
            'rget, e.g., Word, Excel, or a TUOTextTarget-enabled window.  You' +
            ' can use the Shift and Ctrl keys to decide whether a move or a c' +
            'opy is carried out. '
          WordWrap = True
        end
        object ListBox2: TListBox
          Left = 16
          Top = 32
          Width = 121
          Height = 193
          DragMode = dmAutomatic
          ItemHeight = 13
          Items.Strings = (
            'Apples'
            'Bananas'
            'Peaches'
            'Pears'
            'Nectarines'
            'Tomatoes'
            'Oranges'
            'Plums')
          MultiSelect = True
          TabOrder = 0
          OnStartDrag = ListBox2StartDrag
        end
        object CheckBox2: TCheckBox
          Left = 160
          Top = 96
          Width = 281
          Height = 17
          Caption = 'Display confirmation message before drop'
          State = cbChecked
          TabOrder = 1
        end
      end
      object TabSheet4: TTabSheet
        Caption = 'Drag demo &3'
        object Label10: TLabel
          Left = 16
          Top = 16
          Width = 120
          Height = 13
          Caption = 'Tree View, Copy or Move'
        end
        object Label11: TLabel
          Left = 16
          Top = 126
          Width = 114
          Height = 13
          Caption = 'List View, Copy or Move'
        end
        object Label12: TLabel
          Left = 304
          Top = 32
          Width = 225
          Height = 57
          AutoSize = False
          Caption = 
            'Drag selections from this tree view to any valid drop target, e.' +
            'g., Word, Excel, or a TUOTextTarget-enabled window. '
          WordWrap = True
        end
        object Label13: TLabel
          Left = 304
          Top = 142
          Width = 225
          Height = 57
          AutoSize = False
          Caption = 
            'Drag selections from this list view to any valid drop target, e.' +
            'g., Word, Excel, or a TUOTextTarget-enabled window. '
          WordWrap = True
        end
        object TreeView1: TTreeView
          Left = 16
          Top = 32
          Width = 265
          Height = 81
          ReadOnly = True
          DragMode = dmAutomatic
          Indent = 19
          Items.Data = {
            030000001D0000000000000000000000FFFFFFFFFFFFFFFF0000000000000000
            04746869731B0000000000000000000000FFFFFFFFFFFFFFFF00000000020000
            000269731A0000000000000000000000FFFFFFFFFFFFFFFF0000000001000000
            01611D0000000000000000000000FFFFFFFFFFFFFFFF00000000010000000474
            6573741D0000000000000000000000FFFFFFFFFFFFFFFF000000000000000004
            6974656D1C0000000000000000000000FFFFFFFFFFFFFFFF0000000001000000
            0366756E1E0000000000000000000000FFFFFFFFFFFFFFFF0000000001000000
            0569736E27741C0000000000000000000000FFFFFFFFFFFFFFFF000000000000
            00000369743F200000000000000000000000FFFFFFFFFFFFFFFF000000000200
            000007616E6F746865721D0000000000000000000000FFFFFFFFFFFFFFFF0000
            00000000000004746573741E0000000000000000000000FFFFFFFFFFFFFFFF00
            000000000000000568656C6C6F}
          TabOrder = 0
          OnStartDrag = TreeView1StartDrag
        end
        object ListView1: TListView
          Left = 16
          Top = 142
          Width = 265
          Height = 90
          Columns = <
            item
              Caption = 'Col 1'
              Width = 65
            end
            item
              Caption = 'Col 2'
              Width = 65
            end
            item
              Caption = 'Col 3'
              Width = 65
            end
            item
              Caption = 'Col 4'
            end>
          DragMode = dmAutomatic
          ReadOnly = True
          MultiSelect = True
          OnStartDrag = ListView1StartDrag
          TabOrder = 1
          ViewStyle = vsReport
        end
        object CheckBox4: TCheckBox
          Left = 304
          Top = 184
          Width = 137
          Height = 17
          Caption = 'Multi-select list view'
          State = cbChecked
          TabOrder = 2
          OnClick = CheckBox4Click
        end
        object CheckBox5: TCheckBox
          Left = 305
          Top = 80
          Width = 233
          Height = 17
          Caption = 'Drop path to node (see OnAfterDrop handler)'
          TabOrder = 3
        end
        object RadioGroup1: TRadioGroup
          Left = 304
          Top = 204
          Width = 217
          Height = 49
          Caption = 'List View style'
          Columns = 2
          ItemIndex = 3
          Items.Strings = (
            'Icon'
            'Small Icon'
            'List'
            'Report')
          TabOrder = 4
          OnClick = RadioGroup1Click
        end
      end
      object TabSheet7: TTabSheet
        Caption = 'Drag demo &4'
        object Label26: TLabel
          Left = 16
          Top = 16
          Width = 104
          Height = 13
          Caption = 'Bitmap, Copy or Move'
        end
        object Label27: TLabel
          Left = 304
          Top = 32
          Width = 225
          Height = 57
          AutoSize = False
          Caption = 
            'Drag this bitmap to any valid drop target, e.g., Word, Excel, or' +
            ' a TUOGraphicTarget-enabled window. '
          WordWrap = True
        end
        object Image2: TImage
          Left = 16
          Top = 33
          Width = 122
          Height = 57
          DragMode = dmAutomatic
          Picture.Data = {
            07544269746D6170D21F0000424DD21F00000000000036040000280000007A00
            .....lines removed for brevity.....
            D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D20000}
          OnStartDrag = Image2StartDrag
        end
        object Label28: TLabel
          Left = 16
          Top = 108
          Width = 109
          Height = 13
          Caption = 'Metafile, Copy or Move'
        end
        object Label29: TLabel
          Left = 304
          Top = 125
          Width = 225
          Height = 57
          AutoSize = False
          Caption = 
            'Drag this metafile to any valid drop target, e.g., Word, Excel, ' +
            'or a TUOGraphicTarget-enabled window. '
          WordWrap = True
        end
        object Image3: TImage
          Left = 16
          Top = 126
          Width = 185
          Height = 105
          DragMode = dmAutomatic
          Picture.Data = {
            09544D65746166696C65DA3B0000D7CDC69A000000000000D50BDC0640020000
            .....lines removed for brevity.....
            F50BB208}
          Stretch = True
          OnStartDrag = Image3StartDrag
        end
        object Panel6: TPanel
          Left = 304
          Top = 179
          Width = 217
          Height = 49
          DragMode = dmAutomatic
          Caption = 'Drag from here for form image'
          TabOrder = 0
          OnStartDrag = Panel6StartDrag
        end
      end
      object TabSheet2: TTabSheet
        Caption = 'Drop demo &A '
        object Label5: TLabel
          Left = 16
          Top = 16
          Width = 136
          Height = 13
          Caption = 'Memo: Accepts text or URLs'
        end
        object Label6: TLabel
          Left = 280
          Top = 16
          Width = 141
          Height = 13
          Caption = 'ListBox: Accepts text or URLs'
        end
        object Label7: TLabel
          Left = 471
          Top = 16
          Width = 66
          Height = 13
          Alignment = taRightJustify
          Caption = 'Files dropped!'
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clRed
          Font.Height = -11
          Font.Name = 'MS Sans Serif'
          Font.Style = []
          ParentFont = False
          Visible = False
        end
        object Label8: TLabel
          Left = 16
          Top = 200
          Width = 249
          Height = 33
          AutoSize = False
          Caption = 'Drop text from another application onto this memo.'
        end
        object Label9: TLabel
          Left = 277
          Top = 200
          Width = 249
          Height = 33
          AutoSize = False
          Caption = 'Drop text from another application onto this list box.'
        end
        object Label24: TLabel
          Left = 16
          Top = 224
          Width = 505
          Height = 21
          AutoSize = False
        end
        object Memo1: TMemo
          Left = 16
          Top = 32
          Width = 249
          Height = 118
          ScrollBars = ssBoth
          TabOrder = 0
        end
        object ListBox3: TListBox
          Left = 280
          Top = 32
          Width = 257
          Height = 119
          ItemHeight = 13
          TabOrder = 1
        end
        object CheckBox3: TCheckBox
          Left = 280
          Top = 173
          Width = 257
          Height = 17
          Caption = 'Prompt to clear the list before dropping'
          TabOrder = 2
        end
        object CheckBox9: TCheckBox
          Left = 16
          Top = 156
          Width = 249
          Height = 17
          Caption = 'Accept MS IE or MS FrontPage text as HTML'
          TabOrder = 3
          OnClick = CheckBox9Click
        end
        object CheckBox10: TCheckBox
          Left = 280
          Top = 156
          Width = 249
          Height = 17
          Caption = 'Accept files from Explorer, Winzip, etc'
          TabOrder = 4
          OnClick = CheckBox10Click
        end
        object CheckBox11: TCheckBox
          Left = 16
          Top = 173
          Width = 249
          Height = 17
          Caption = 'Accept MS Rich Text Format (RTF)'
          TabOrder = 5
          OnClick = CheckBox11Click
        end
      end
      object TabSheet6: TTabSheet
        Caption = 'Drop demo &B'
        object Label25: TLabel
          Left = 17
          Top = 13
          Width = 99
          Height = 13
          Caption = 'Accepts image drops'
        end
        object Label30: TLabel
          Left = 16
          Top = 200
          Width = 265
          Height = 29
          AutoSize = False
          Caption = 
            'Drop a picture from another application (e.g., Word, Excel, Inte' +
            'rnet Explorer) here.'
          WordWrap = True
        end
        object Label31: TLabel
          Left = 136
          Top = 13
          Width = 142
          Height = 13
          Alignment = taRightJustify
          AutoSize = False
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clRed
          Font.Height = -11
          Font.Name = 'MS Sans Serif'
          Font.Style = []
          ParentFont = False
        end
        object Panel5: TPanel
          Left = 16
          Top = 32
          Width = 265
          Height = 161
          BevelOuter = bvNone
          TabOrder = 0
          object ScrollBox1: TScrollBox
            Left = 0
            Top = 0
            Width = 265
            Height = 161
            HorzScrollBar.Tracking = True
            VertScrollBar.Tracking = True
            Align = alClient
            TabOrder = 0
            object Image1: TImage
              Left = 0
              Top = 0
              Width = 259
              Height = 155
              AutoSize = True
              DragMode = dmAutomatic
              OnStartDrag = Image1StartDrag
            end
          end
        end
        object CheckBox6: TCheckBox
          Left = 313
          Top = 15
          Width = 200
          Height = 17
          Caption = 'Stretch dropped image to fit'
          TabOrder = 1
          OnClick = CheckBox6Click
        end
        object RadioGroup2: TRadioGroup
          Left = 304
          Top = 56
          Width = 225
          Height = 65
          Caption = 'Preferred graphic format to accept'
          Items.Strings = (
            'Enhanced &metafile'
            '&Bitmap')
          TabOrder = 2
          OnClick = RadioGroup2Click
        end
        object CheckBox7: TCheckBox
          Left = 306
          Top = 130
          Width = 223
          Height = 17
          Caption = 'Accept preferred format only'
          TabOrder = 3
          OnClick = CheckBox7Click
        end
        object CheckBox8: TCheckBox
          Left = 306
          Top = 149
          Width = 223
          Height = 17
          Caption = 'Allow drags from this image'
          TabOrder = 4
        end
      end
      object TabSheet5: TTabSheet
        Caption = '&About'
        object Panel3: TPanel
          Left = 0
          Top = 0
          Width = 548
          Height = 257
          Align = alClient
          BevelOuter = bvNone
          BorderWidth = 3
          TabOrder = 0
          object GroupBox1: TGroupBox
            Left = 3
            Top = 3
            Width = 542
            Height = 251
            Align = alClient
            Caption = 'About the UnitOOPS Software Drag and Drop Components'
            TabOrder = 0
            object Panel4: TPanel
              Left = 2
              Top = 15
              Width = 538
              Height = 234
              Align = alClient
              BevelOuter = bvNone
              BorderWidth = 10
              TabOrder = 0
              object Label19: TLabel
                Left = 10
                Top = 130
                Width = 518
                Height = 14
                Align = alTop
                Alignment = taCenter
                AutoSize = False
                Caption = 'Web:  http://www.pobox.com/~unitoops'
                WordWrap = True
              end
              object Label18: TLabel
                Left = 10
                Top = 73
                Width = 518
                Height = 15
                Align = alTop
                AutoSize = False
                Caption = 'Contact UnitOOPS Software at:'
                Font.Charset = DEFAULT_CHARSET
                Font.Color = clActiveCaption
                Font.Height = -11
                Font.Name = 'MS Sans Serif'
                Font.Style = [fsBold]
                ParentFont = False
              end
              object Label21: TLabel
                Left = 10
                Top = 10
                Width = 518
                Height = 63
                Align = alTop
                AutoSize = False
                Caption = 
                  'Add inter-application drag and drop of text and graphics to your' +
                  ' Delphi applications quickly and easily with these simple-to-use' +
                  ' components.'
                WordWrap = True
              end
              object Label22: TLabel
                Left = 10
                Top = 88
                Width = 518
                Height = 14
                Align = alTop
                Alignment = taCenter
                AutoSize = False
                Caption = '132 Cherry Hill Road'
                WordWrap = True
              end
              object Label23: TLabel
                Left = 10
                Top = 102
                Width = 518
                Height = 14
                Align = alTop
                Alignment = taCenter
                AutoSize = False
                Caption = 'Orange, CT 06477, USA'
                WordWrap = True
              end
              object Label20: TLabel
                Left = 10
                Top = 116
                Width = 518
                Height = 14
                Align = alTop
                Alignment = taCenter
                AutoSize = False
                Caption = 'E-mail:  unitoops@pobox.com'
                WordWrap = True
              end
            end
          end
        end
      end
    end
  end
  object UOTextSource1: TUOTextSource
    OnBeforeDrop = UOTextSource2BeforeDrop
    DropEffects = [deCopy]
    DonorComponent = ListBox1
    Left = 16
    Top = 246
  end
  object UOTextTarget1: TUOTextTarget
    AcceptorControl = Memo1
    AcceptTextFormats = [dtfURL, dtfText]
    OnDragEnter = UOTextTarget1DragEnter
    OnDragOver = UOTextTarget1DragOver
    OnDragLeave = UOTextTarget1DragLeave
    OnDrop = UOTextTarget1Drop
    Left = 158
    Top = 247
  end
  object UOTextTarget2: TUOTextTarget
    AcceptorControl = ListBox3
    AcceptTextFormats = [dtfURL, dtfText]
    OnDrop = UOTextTarget2Drop
    Left = 190
    Top = 247
  end
  object UOTextSource2: TUOTextSource
    OnBeforeDrop = UOTextSource2BeforeDrop
    OnAfterDrop = UOTextSource2AfterDrop
    Text = 'Apples'
    DropEffects = [deCopy, deMove]
    DonorComponent = ListBox2
    Left = 47
    Top = 246
  end
  object UOTextSource3: TUOTextSource
    OnBeforeDrop = UOTextSource3BeforeDrop
    OnAfterDrop = UOTextSource3AfterDrop
    DropEffects = [deCopy, deMove]
    DonorComponent = TreeView1
    Left = 79
    Top = 246
  end
  object UOTextSource4: TUOTextSource
    OnAfterDrop = UOTextSource4AfterDrop
    DropEffects = [deCopy, deMove]
    DonorComponent = ListView1
    Left = 110
    Top = 246
  end
  object UOGraphicTarget1: TUOGraphicTarget
    AcceptorControl = Panel5
    AcceptGraphicFormats = [dgfMetafile, dgfBitmap]
    PreferredFormat = dgfMetafile
    OnDrop = UOGraphicTarget1Drop
    Left = 431
    Top = 246
  end
  object UOGraphicSource1: TUOGraphicSource
    Picture.Data = {
      07544269746D6170D21F0000424DD21F00000000000036040000280000007A00
      .....lines removed for brevity.....
      D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D20000}
    DropEffects = [deCopy]
    DonorImage = Image2
    Left = 287
    Top = 246
  end
  object UOGraphicSource2: TUOGraphicSource
    Picture.Data = {
      09544D65746166696C65DA3B0000D7CDC69A000000000000D50BDC0640020000
      .....lines removed for brevity.....
      F50BB208}
    DropEffects = [deCopy]
    DonorImage = Image3
    Left = 319
    Top = 246
  end
  object UOGraphicSource3: TUOGraphicSource
    DropEffects = [deCopy]
    DonorImage = Image1
    Left = 350
    Top = 246
  end
  object UOGraphicSource4: TUOGraphicSource
    DropEffects = [deCopy]
    Left = 382
    Top = 246
  end
end
Back to top

Back to the examples page